diff --git a/doc/usage/theming.rst b/doc/usage/theming.rst index f66734b9671..72bb81578ae 100644 --- a/doc/usage/theming.rst +++ b/doc/usage/theming.rst @@ -158,9 +158,15 @@ These themes are: 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). - - **navigation_with_keys** (true or false): Allow navigating to the - previous/next page using the keyboard's left and right arrows. Defaults to - ``False``. + - **navigation_with_keys** (true or false): Allow navigating + with the following keyboard shortcuts: + + - :kbd:`Left arrow`: previous page + - :kbd:`Right arrow`: next page + - :kbd:`/`: jump to Quick search + - :kbd:`Esc`: hide search matches + + Defaults to ``False``. - **globaltoc_collapse** (true or false): Only expand subsections of the current document in ``globaltoc.html`` diff --git a/sphinx/themes/basic/static/doctools.js b/sphinx/themes/basic/static/doctools.js index 86420becac7..3dd626eced0 100644 --- a/sphinx/themes/basic/static/doctools.js +++ b/sphinx/themes/basic/static/doctools.js @@ -294,21 +294,25 @@ var Documentation = { if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT' && activeElementType !== 'BUTTON' && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) { - switch (event.keyCode) { - case 37: // left + switch (event.key) { + case 'ArrowLeft': var prevHref = $('link[rel="prev"]').prop('href'); if (prevHref) { window.location.href = prevHref; return false; } - break; - case 39: // right + case 'ArrowRight': var nextHref = $('link[rel="next"]').prop('href'); if (nextHref) { window.location.href = nextHref; return false; } - break; + case '/': + $('input[name=q]').first().focus(); + return false; + case 'Escape': + Documentation.hideSearchWords(); + return false; } } });