Enable keyboard navigation for Python docs#148751
Enable keyboard navigation for Python docs#148751abitrolly wants to merge 2 commits intopython:mainfrom
Conversation
You can test how it works before this change by setting DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS = true in JavaScript console and press Left on the keyboard.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Copying my comment from python/devguide#1784 (comment): Nice little shortcut, but I'm concerned this will interfere with keyboard handling for people using assistive tech such as screen readers. https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/ includes:
https://webaim.org/techniques/keyboard/ has examples where |
@hugovk keyboard shortcuts are disabled for these HTML elements - "TEXTAREA", "INPUT", "SELECT", "BUTTON" (https://github.com/sphinx-doc/sphinx/blob/cc7c6f435ad37bb12264f8118c8461b230e6830c/sphinx/themes/basic/static/doctools.js#L6-L11) Is that enough for Python docs? The ARIA guidelines are too generic - they say "Consider, for example, a screen reader user operating a tree.", but as far as I can tell there are no expandable trees in Python docs. |
|
My understanding is that screen readers use left and right to navigate character-by-character:
https://tink.uk/understanding-screen-reader-interaction-modes/
Or for navigating table cells: https://dequeuniversity.com/screenreaders/nvda-keyboard-shortcuts So any other interception of arrow keys would be a problem. |
If the screen reader indeed intercepts the left/right keys to provide its own functions, then the problem doesn't exist. We need a screen reader user to test that https://cpython-previews--148751.org.readthedocs.build/en/148751/tutorial/index.html page doesn't trigger navigation to next when right arrow key is pressed while screen reader is active. The link goes to the tutorial page, because front page doesn't have |
You can test how it works before this change by opening JavaScript console with F12 and setting
then make sure the focus is in the main are and press Left on the keyboard.
The option is documented here https://www.sphinx-doc.org/en/master/usage/theming.html#:~:text=navigation%5Fwith%5Fkeys
📚 Documentation preview 📚: https://cpython-previews--148751.org.readthedocs.build/