aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2022-11-15 01:08:08 +0000
committerBen Harris <bjh21@bjh21.me.uk>2023-01-19 20:34:48 +0000
commit1d509dc81961f182629bf0bfd48eed7941122fab (patch)
tree82fc5707d400ea0c5b970f2c018baf89d791d158
parent27c97c0ffdda0b91fecf155f3bc29b32ed806bb2 (diff)
downloadpuzzles-1d509dc81961f182629bf0bfd48eed7941122fab.zip
puzzles-1d509dc81961f182629bf0bfd48eed7941122fab.tar.gz
puzzles-1d509dc81961f182629bf0bfd48eed7941122fab.tar.bz2
puzzles-1d509dc81961f182629bf0bfd48eed7941122fab.tar.xz
js: Have the "SoftRight" key open the menu by focussing it
-rw-r--r--emccpre.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/emccpre.js b/emccpre.js
index 8e957a0..2bbaa57 100644
--- a/emccpre.js
+++ b/emccpre.js
@@ -530,6 +530,7 @@ function initPuzzle() {
// Prevent default even if we didn't do anything, as long as this
// was an interesting key.
event.preventDefault();
+ event.stopPropagation();
}
menuform.addEventListener("keydown", menukey);
@@ -558,6 +559,16 @@ function initPuzzle() {
}
}, true);
+ document.addEventListener("keydown", function(event) {
+ // Key to open the menu on KaiOS.
+ if (event.key == "SoftRight" &&
+ !menuform.contains(document.activeElement)) {
+ menuform.querySelector("li div").focus();
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }, true);
+
// Event handler to fake :focus-within on browsers too old for
// it (like KaiOS 2.5). Browsers without :focus-within are also
// too old for focusin/out events, so we have to use focus events