Disable arrow keys when a modifier key is pressed (#7089)

* Disable arrow keys when a modifier key is pressed

Closes #7088.

* #7088 document key navigation option

* add change note for #7088

Co-authored-by: Timotheus Kampik <timotheus.kampik@signavio.com>
This commit is contained in:
Matthias Geier 2020-02-07 13:08:51 +01:00 committed by GitHub
parent 4198219bb1
commit 327778ca22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -82,6 +82,9 @@ Bugs fixed
module members without :impoprted-members: option module members without :impoprted-members: option
* #6889: autodoc: Trailing comma in ``:members::`` option causes cryptic warning * #6889: autodoc: Trailing comma in ``:members::`` option causes cryptic warning
* #7055: linkcheck: redirect is treated as an error * #7055: linkcheck: redirect is treated as an error
* #7088: HTML template: If ``navigation_with_keys`` option is activated,
modifier keys are ignored, which means the feature can interfere with browser
features
* #7090: std domain: Can't assign numfig-numbers for custom container nodes * #7090: std domain: Can't assign numfig-numbers for custom container nodes
Testing Testing

View File

@ -151,6 +151,10 @@ These themes are:
dimension string such as '70em' or '50%'. Use 'none' if you don't dimension string such as '70em' or '50%'. Use 'none' if you don't
want a width limit. Defaults may depend on the theme (often 800px). want a width limit. Defaults may depend on the theme (often 800px).
- **navigation_with_keys** (true or false): Allow navigating to the
previous/next page using the keyboard's left and right arrows. Defaults to
``False``.
**alabaster** **alabaster**
`Alabaster theme`_ is a modified "Kr" Sphinx theme from @kennethreitz `Alabaster theme`_ is a modified "Kr" Sphinx theme from @kennethreitz
(especially as used in his Requests project), which was itself originally (especially as used in his Requests project), which was itself originally

View File

@ -283,10 +283,11 @@ var Documentation = {
}, },
initOnKeyListeners: function() { initOnKeyListeners: function() {
$(document).keyup(function(event) { $(document).keydown(function(event) {
var activeElementType = document.activeElement.tagName; var activeElementType = document.activeElement.tagName;
// don't navigate when in search box or textarea // don't navigate when in search box or textarea
if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT') { if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT'
&& !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
switch (event.keyCode) { switch (event.keyCode) {
case 37: // left case 37: // left
var prevHref = $('link[rel="prev"]').prop('href'); var prevHref = $('link[rel="prev"]').prop('href');