>
> I agree that hot key discoverability could be better, but I don't think
> this is an issue in the PostgreSQL documentation; it's something the
> browser should handle.  The job of the HTML markup is to declare the key
> -- then it's up to the browser how to present it.  Otherwise, every
> single web page in the world (well, those with hot keys) would have to
> repeat this analysis, which seems on the wrong level to me.
>

I agree that that's a thing that browsers *should* be doing, but presently
none are (as far as I know), and the history of web development has many
examples of websites having to write crutches for deficient browsers so
that their users can have a decent experience, with the definition of
decent experience shifting over time.

Attached is a patch to add the nav- tags to the header (could just as
easily have done the footer) for up/down/left/right and the javascript to
find those ids and simulate a click. I've tested this on chrome (where
accesskeys work with alt+ ) and firefox (where accesskeys don't seem to
work at all) and it works as expected in both places. The javascript itself
is rather naive, but serves as a starting point for discussion.

In researching accesskey, I've noticed that the accesskey="t" stylesheet
section doesn't get rendered in our html anywhere. Was "t" = "table of
contents"? Seems like something we could delete until we need it again.
From c9a3d11cb8402c08b256adbc7b9ea1a3d3e7ff93 Mon Sep 17 00:00:00 2001
From: coreyhuinker <corey.huin...@gmail.com>
Date: Wed, 18 Jan 2023 16:00:10 -0500
Subject: [PATCH v1] Add javascript to enable up/next/previous navigation via
 arrow keys

---
 doc/src/sgml/stylesheet-speedup-xhtml.xsl | 6 ++++++
 doc/src/sgml/stylesheet.xsl               | 8 ++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/doc/src/sgml/stylesheet-speedup-xhtml.xsl b/doc/src/sgml/stylesheet-speedup-xhtml.xsl
index da0f2b5a97..d7e63ab38f 100644
--- a/doc/src/sgml/stylesheet-speedup-xhtml.xsl
+++ b/doc/src/sgml/stylesheet-speedup-xhtml.xsl
@@ -339,6 +339,12 @@
     </xsl:if>
 
     <xsl:call-template name="user.head.content"/>
+
+    <script>document.addEventListener("keydown", function(event) { event.preventDefault();
+      if (event.key == "ArrowLeft") { document.getElementById('nav-prev').click(); }
+      else if (event.key == "ArrowRight") { document.getElementById('nav-next').click(); }
+      else if (event.key == "ArrowUp") { document.getElementById('nav-up').click(); } });
+    </script>
   </head>
 </xsl:template>
 
diff --git a/doc/src/sgml/stylesheet.xsl b/doc/src/sgml/stylesheet.xsl
index b6141303ab..6fe3c51e18 100644
--- a/doc/src/sgml/stylesheet.xsl
+++ b/doc/src/sgml/stylesheet.xsl
@@ -72,7 +72,7 @@ Customization of header
             <tr>
               <td width="10%" align="{$direction.align.start}">
                 <xsl:if test="count($prev)>0">
-                  <a accesskey="p">
+                  <a accesskey="p" id="nav-prev">
                     <xsl:attribute name="href">
                       <xsl:call-template name="href.target">
                         <xsl:with-param name="object" select="$prev"/>
@@ -91,7 +91,7 @@ Customization of header
               <td width="10%" align="{$direction.align.start}">
                 <xsl:choose>
                   <xsl:when test="count($up)&gt;0">
-                    <a accesskey="u">
+                    <a accesskey="u" id="nav-up">
                       <xsl:attribute name="href">
                         <xsl:call-template name="href.target">
                           <xsl:with-param name="object" select="$up"/>
@@ -120,7 +120,7 @@ Customization of header
               <td width="10%" align="{$direction.align.end}">
                 <xsl:choose>
                   <xsl:when test="$home != . or $nav.context = 'toc'">
-                    <a accesskey="h">
+                    <a accesskey="h" id="nav-home">
                       <xsl:attribute name="href">
                         <xsl:call-template name="href.target">
                           <xsl:with-param name="object" select="$home"/>
@@ -143,7 +143,7 @@ Customization of header
               <td width="10%" align="{$direction.align.end}">
                 <xsl:text>&#160;</xsl:text>
                 <xsl:if test="count($next)>0">
-                  <a accesskey="n">
+                  <a accesskey="n" id="nav-next">
                     <xsl:attribute name="href">
                       <xsl:call-template name="href.target">
                         <xsl:with-param name="object" select="$next"/>
-- 
2.39.0

Reply via email to