Support any of /sS to focus docs search

This commit is contained in:
Lonami Exo 2019-01-26 13:04:19 +01:00
parent c11d71c3cd
commit cf867954c3

View File

@ -218,6 +218,18 @@ function getQuery(name) {
}
}
document.onkeydown = function (e) {
if (e.key == '/' || e.key == 's' || e.key == 'S') {
if (document.activeElement != searchBox) {
searchBox.focus();
return false;
}
} else if (e.key == '?') {
alert('Pressing any of: /sS\nWill focus the search bar\n\n' +
'Pressing: enter\nWill navigate to the first match')
}
}
var query = getQuery('q');
if (query) {
searchBox.value = query;