Skip to content

Commit 9f099e7

Browse files
committed
Implement new shortcuts:
- "s" and "/" for Focus search bar - "h" - clear highlighted text Fixes #691.
1 parent c66b3ad commit 9f099e7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

sphinx/themes/basic/static/doctools.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,21 +294,26 @@ var Documentation = {
294294
if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT'
295295
&& activeElementType !== 'BUTTON' && !event.altKey && !event.ctrlKey && !event.metaKey
296296
&& !event.shiftKey) {
297-
switch (event.keyCode) {
298-
case 37: // left
297+
switch (event.key) {
298+
case 'ArrowLeft':
299299
var prevHref = $('link[rel="prev"]').prop('href');
300300
if (prevHref) {
301301
window.location.href = prevHref;
302302
return false;
303303
}
304-
break;
305-
case 39: // right
304+
case 'ArrowRight':
306305
var nextHref = $('link[rel="next"]').prop('href');
307306
if (nextHref) {
308307
window.location.href = nextHref;
309308
return false;
310309
}
311-
break;
310+
case '/':
311+
case 's':
312+
$('input[name=q]').focus();
313+
return false;
314+
case 'h':
315+
Documentation.hideSearchWords();
316+
return false;
312317
}
313318
}
314319
});

0 commit comments

Comments
 (0)