mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
kaios: Make F10 open and close the menu
This is no use on KaiOS itself, but provides a way to open the menu from the keyboard on desktop browsers for testing (and for keyboard-accessibility in general).
This commit is contained in:
@ -491,7 +491,7 @@ function initPuzzle() {
|
|||||||
if (dlg_dimmer !== null)
|
if (dlg_dimmer !== null)
|
||||||
return;
|
return;
|
||||||
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Enter",
|
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Enter",
|
||||||
"Escape", "Backspace", "SoftRight"]
|
"Escape", "Backspace", "SoftRight", "F10"]
|
||||||
.includes(event.key))
|
.includes(event.key))
|
||||||
return;
|
return;
|
||||||
if (ishorizontal(thismenu)) {
|
if (ishorizontal(thismenu)) {
|
||||||
@ -535,7 +535,7 @@ function initPuzzle() {
|
|||||||
else if (event.key == "Enter")
|
else if (event.key == "Enter")
|
||||||
event.target.click();
|
event.target.click();
|
||||||
else if (event.key == "Escape" || event.key == "SoftRight" ||
|
else if (event.key == "Escape" || event.key == "SoftRight" ||
|
||||||
event.key == "Backspace")
|
event.key == "F10" || event.key == "Backspace")
|
||||||
// Leave the menu entirely.
|
// Leave the menu entirely.
|
||||||
onscreen_canvas.focus();
|
onscreen_canvas.focus();
|
||||||
// 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
|
||||||
@ -599,7 +599,7 @@ function initPuzzle() {
|
|||||||
|
|
||||||
document.addEventListener("keydown", function(event) {
|
document.addEventListener("keydown", function(event) {
|
||||||
// Key to open the menu on KaiOS.
|
// Key to open the menu on KaiOS.
|
||||||
if (event.key == "SoftRight" &&
|
if ((event.key == "SoftRight" || event.key == "F10") &&
|
||||||
!menuform.contains(document.activeElement)) {
|
!menuform.contains(document.activeElement)) {
|
||||||
menuform.querySelector("li div").focus();
|
menuform.querySelector("li div").focus();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
Reference in New Issue
Block a user