js: Have the "SoftRight" key open the menu by focussing it

This commit is contained in:
Ben Harris
2022-11-15 01:08:08 +00:00
parent 27c97c0ffd
commit 1d509dc819

View File

@ -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