Accessibility - Use modifiers for chapter nav and add shortkey settings #2061
+449
−185
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #518 and #1789. Supersedes #2043.
This PR changes the default chapter navigation key combos from bare ← and → to Ctrl+← and Ctrl+→ (Windows) or ⌘+← and ⌘+→ (Mac). The bare arrow key combos are bad for accessibility and very easy to press by mistake for users who expect arrow keys to scroll the page, which is the usual and expected behavior. Hitboxes of the chapter navigation buttons are also reduced to prevent accidental clicks.
It also adds options to make all shortkeys user-configurable. These options are included in the new Settings menu, which also allows for setting the theme and takes the place of the Theme menu in the menu bar. The new options make it easy for users to switch back to the old behavior if desired or choose their own key combinations to avoid any functionality clashes with screen readers, browser extensions, or other 3rd-party software.
Shortcuts for all keyboard-accessible elements are also surfaced to users on hover by appending them to the
title
of the relevant elements, and to assistive software by settingaria-keyshortcuts
.The options also allow configuring the shortkeys for Toggle Table of Contents, Search, and Open settings.
Finally, all shortkeys are temporarily disabled whenever the currently focused element is an
input
,textarea
, or iscontentEditable
. This should fix issues of unexpected behavior in books that use custom editable elements.