Skip to content

Commit

Permalink
Implement new shortcuts:
Browse files Browse the repository at this point in the history
- "s" and "/" for Focus search bar
- "h" - clear highlighted text

Fixes #691.
  • Loading branch information
marxin committed Aug 11, 2021
1 parent c66b3ad commit 9f099e7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions sphinx/themes/basic/static/doctools.js
Expand Up @@ -294,21 +294,26 @@ 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 '/':
case 's':
$('input[name=q]').focus();
return false;
case 'h':
Documentation.hideSearchWords();
return false;
}
}
});
Expand Down

0 comments on commit 9f099e7

Please sign in to comment.