-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Right now we add a keydown event listener, so we can act on the "botton down" event already - which feels more responsive than waiting for the "button up" event. The downside is, we have to re-implement special keys such as backspace and remove the last character from the right.
Lines 49 to 68 in e81a7f7
| postcode.addEventListener("keydown", function (e) { | |
| var code; | |
| // We want to fitBounds when the key is down already; | |
| // this means we have to handle special keys such as | |
| // backspace manually and delete the last character. | |
| // Maybe there is a better way, because this e.g. | |
| // doesn't handle text copy & paste or cut events. | |
| if (e.keyCode === 8) { // backspace | |
| code = postcode.value.slice(0, Math.max(0, postcode.value.length - 1)); | |
| } else { | |
| var digit = parseInt(e.key, 10); | |
| if (isNaN(digit) || postcode.value.length >= 5) { | |
| return; | |
| } | |
| code = postcode.value.concat(digit); | |
| } |
This is pretty hacky, does not work with composite keys (think ctrl+x), and it does not seem to work properly on Firefox for Android.
We should look into improving the user experience around the input field.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels