Skip to content

Commit 8c2515a

Browse files
committed
Implement new shortcuts:
- "s" and "/" for Focus search bar - "c" - clear highlighted test Fixes #691.
1 parent 805fd98 commit 8c2515a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

sphinx/themes/basic/static/doctools.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,20 +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
}
310+
case '/':
311+
case 's':
312+
$('input[name=q]').focus();
313+
return false;
314+
case 'c':
315+
newurl = window.location.href.replace(new RegExp('\\?highlight=[^#]*'), '');
316+
window.location.href = newurl;
311317
break;
312318
}
313319
}

0 commit comments

Comments
 (0)