PreTeXtBook / pretext

PreTeXt: an authoring and publishing system for scholarly documents
https://pretextbook.org
Other
254 stars 203 forks source link

Bind arrow keys to navigation #2069

Open Alex-Jordan opened 8 months ago

Alex-Jordan commented 8 months ago

It would be nice if I could keyboard navigate to the "Next" page with the right arrow key, etc.

I would try adding this feature myself, but I'm afraid there are too many moving parts with JS in script tags, JS from JS Core, and React.

rbeezer commented 8 months ago

Good idea.

But, total speculation: what if some interactive (like MathJax Explorer) wanted that key also and had the focus?

Alex-Jordan commented 8 months ago

The behavior of the key should be that of the interactive thingy if focus is within that thingy.

In normal webpage use, the up/down arrow keys will scroll the page up and down. Now imagine some element is tall, but constrained in height, and has overflow:scroll. When focus gets inside that thing, up/down changes to scrolling up and down within that thing. So I reckon it should be a bit like this when something smaller wants the left/right keys too.

Here are some relevant opinions: https://ux.stackexchange.com/questions/59643/is-it-okay-to-map-the-left-right-arrow-keys-to-a-websites-navigation

I do find that sometimes a table in PTX is rigidly too wide for a small screen, and horizontal scrolling comes into play. And then there would be conflict between using left/right for that scrolling and for page navigation.

kcrisman commented 8 months ago

The behavior of the key should be that of the interactive thingy if focus is within that thingy.

In normal webpage use, the up/down arrow keys will scroll the page up and down. Now imagine some element is tall, but constrained in height, and has overflow:scroll. When focus gets inside that thing, up/down changes to scrolling up and down within that thing. So I reckon it should be a bit like this when something smaller wants the left/right keys too.

Just to make sure that any such navigation doesn't mess up slides, which inherit some conversion stuff from html - presumably js as well? The way that is supposed to work is inherited from reveal.js right, as far as I have observed.

Message ID: @.***>

Alex-Jordan commented 8 months ago

A more conventional case: typing in any kind of input field, the arrow keys should do their usual thing, not take you to a new page.