diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2022-10-25 10:24:15 +0100 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2022-10-25 20:13:59 +0100 |
| commit | e6faebeb9a1856c9ea7140eb650b48ada0adc923 (patch) | |
| tree | 12e06818181e158e1bd23dba2b176a29b7f79558 | |
| parent | 43c89dd5e118cf244b8eb978b13fecfe2240e9e7 (diff) | |
| download | puzzles-e6faebeb9a1856c9ea7140eb650b48ada0adc923.zip puzzles-e6faebeb9a1856c9ea7140eb650b48ada0adc923.tar.gz puzzles-e6faebeb9a1856c9ea7140eb650b48ada0adc923.tar.bz2 puzzles-e6faebeb9a1856c9ea7140eb650b48ada0adc923.tar.xz | |
js: Remove keypress handler
At least in modern browsers (and I suspect in all browsers), cancelling
a keydown event ensures that the subsequent keypress event doesn't fire.
See <https://w3c.github.io/uievents/#keys-cancelable-keys>.
So there's no point in having a handler on keypress events that just
tries to cancel them as well. Removing the handler doesn't do much now,
but it opens the possibility of being a bit more selective about which
keydown events we cancel.
| -rw-r--r-- | emccpre.js | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -304,9 +304,8 @@ function initPuzzle() { } }; - // Set up keyboard handlers. We do all the actual keyboard - // handling in onkeydown; but we also call event.preventDefault() - // in both the keydown and keypress handlers. This means that + // Set up keyboard handlers. We call event.preventDefault() + // in the keydown handler. This means that // while the canvas itself has focus, _all_ keypresses go only to // the puzzle - so users of this puzzle collection in other media // can indulge their instinct to press ^R for redo, for example, @@ -318,9 +317,6 @@ function initPuzzle() { event.shiftKey ? 1 : 0, event.ctrlKey ? 1 : 0); event.preventDefault(); }; - onscreen_canvas.onkeypress = function(event) { - event.preventDefault(); - }; // command() is a C function called to pass back events which // don't fall into other categories like mouse and key events. |