mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
js: Have the "SoftRight" key open the menu by focussing it
This commit is contained in:
11
emccpre.js
11
emccpre.js
@ -530,6 +530,7 @@ function initPuzzle() {
|
|||||||
// Prevent default even if we didn't do anything, as long as this
|
// Prevent default even if we didn't do anything, as long as this
|
||||||
// was an interesting key.
|
// was an interesting key.
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
menuform.addEventListener("keydown", menukey);
|
menuform.addEventListener("keydown", menukey);
|
||||||
|
|
||||||
@ -558,6 +559,16 @@ function initPuzzle() {
|
|||||||
}
|
}
|
||||||
}, true);
|
}, 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
|
// Event handler to fake :focus-within on browsers too old for
|
||||||
// it (like KaiOS 2.5). Browsers without :focus-within are also
|
// it (like KaiOS 2.5). Browsers without :focus-within are also
|
||||||
// too old for focusin/out events, so we have to use focus events
|
// too old for focusin/out events, so we have to use focus events
|
||||||
|
Reference in New Issue
Block a user