aboutsummaryrefslogtreecommitdiff
path: root/emccpre.js
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2022-10-24 23:06:12 +0100
committerBen Harris <bjh21@bjh21.me.uk>2022-10-24 23:13:33 +0100
commit768ef770a351ee1528e6e7923d3b3b00654401cb (patch)
tree89ca8fe8024726c74ca73eb9dc05de4f991b7e11 /emccpre.js
parent0db5fb525bb58056caf9303d2ac159fc51c04e04 (diff)
downloadpuzzles-768ef770a351ee1528e6e7923d3b3b00654401cb.zip
puzzles-768ef770a351ee1528e6e7923d3b3b00654401cb.tar.gz
puzzles-768ef770a351ee1528e6e7923d3b3b00654401cb.tar.bz2
puzzles-768ef770a351ee1528e6e7923d3b3b00654401cb.tar.xz
js: Use KeyboardEvent.key for ASCII keystrokes
This requires passing in KeyboardEvent.location from JavaScript so that we can detect the numeric keypad properly. Out of caution we currently only set MOD_NUM_KEYPAD on numbers, like we always have, but we have enough information to set it on arrow keys, Enter, "+", etc. This finally gets '/' and '\' working in Slant again.
Diffstat (limited to 'emccpre.js')
-rw-r--r--emccpre.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/emccpre.js b/emccpre.js
index 2a71875..450a093 100644
--- a/emccpre.js
+++ b/emccpre.js
@@ -311,10 +311,10 @@ function initPuzzle() {
// the puzzle - so users of this puzzle collection in other media
// can indulge their instinct to press ^R for redo, for example,
// without accidentally reloading the page.
- key = Module.cwrap('key', 'void', ['number', 'string',
- 'string', 'number', 'number']);
+ key = Module.cwrap('key', 'void', ['number', 'string', 'string',
+ 'number', 'number', 'number']);
onscreen_canvas.onkeydown = function(event) {
- key(event.keyCode, event.key, event.char,
+ key(event.keyCode, event.key, event.char, event.location,
event.shiftKey ? 1 : 0, event.ctrlKey ? 1 : 0);
event.preventDefault();
};