aboutsummaryrefslogtreecommitdiff
path: root/html/jspage.pl
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2022-11-12 23:39:05 +0000
committerBen Harris <bjh21@bjh21.me.uk>2022-11-23 21:53:59 +0000
commit52cd58043ac144eeafb92fd962662420506283c1 (patch)
treeba3a8401ead53edeea6bc6278d948ed37e26f368 /html/jspage.pl
parentb1b2da98961c3ec6561a934834026c117f4366d3 (diff)
downloadpuzzles-52cd58043ac144eeafb92fd962662420506283c1.zip
puzzles-52cd58043ac144eeafb92fd962662420506283c1.tar.gz
puzzles-52cd58043ac144eeafb92fd962662420506283c1.tar.bz2
puzzles-52cd58043ac144eeafb92fd962662420506283c1.tar.xz
js: Add keyboard navigation for menus
Once the input focus is in the menu system (for instance by Shift+Tab from the puzzle), you can move left and right through the menu bar and up and down within each menu. Enter selects a menu item. The current menu item is tracked by giving it the input focus.
Diffstat (limited to 'html/jspage.pl')
-rwxr-xr-xhtml/jspage.pl12
1 files changed, 7 insertions, 5 deletions
diff --git a/html/jspage.pl b/html/jspage.pl
index f3b0df5..ec67a4d 100755
--- a/html/jspage.pl
+++ b/html/jspage.pl
@@ -127,7 +127,8 @@ EOF
color: rgba(0,0,0,0.5);
}
-#gamemenu li > :hover:not(:disabled) {
+#gamemenu li > :hover:not(:disabled),
+#gamemenu li > :focus-within {
/* When the mouse is over a menu item, highlight it */
background: rgba(0,0,0,0.3);
}
@@ -184,7 +185,8 @@ EOF
left: inherit; right: 100%;
}
-#gamemenu :hover > ul {
+#gamemenu :hover > ul,
+#gamemenu :focus-within > ul {
/* Last but by no means least, the all-important line that makes
* submenus be displayed! Any <ul> whose parent <li> is being
* hovered over gets display:flex overriding the display:none
@@ -309,13 +311,13 @@ ${unfinishedpara}
<hr>
<div id="puzzle" style="display: none">
<form id="gamemenu"><ul>
- <li><div>Game...<ul>
+ <li><div tabindex="0">Game...<ul>
<li><button type="button" id="specific">Enter game ID</button></li>
<li><button type="button" id="random">Enter random seed</button></li>
<li><button type="button" id="save">Download save file</button></li>
<li><button type="button" id="load">Upload save file</button></li>
</ul></div></li>
- <li><div>Type...<ul id="gametype"></ul></div></li>
+ <li><div tabindex="0">Type...<ul role="menu" id="gametype"></ul></div></li>
<li role="separator"></li>
<li><button type="button" id="new">
New<span class="verbiage"> game</span>
@@ -335,7 +337,7 @@ ${unfinishedpara}
</ul></form>
<div align=center>
<div id="resizable">
- <canvas id="puzzlecanvas" width="1px" height="1px" tabindex="1">
+ <canvas id="puzzlecanvas" width="1px" height="1px" tabindex="0">
</canvas>
<div id="statusbarholder">
</div>