mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
add shortcut to focus searchbar
This commit is contained in:
parent
459389a2da
commit
a50d463700
1 changed files with 14 additions and 2 deletions
|
@ -37,8 +37,9 @@
|
|||
|
||||
searxng.ready(function () {
|
||||
qinput = d.getElementById(qinput_id);
|
||||
const wasSearchBarFound = qinput !== null;
|
||||
|
||||
if (qinput !== null) {
|
||||
if (wasSearchBarFound) {
|
||||
// clear button
|
||||
createClearButton(qinput);
|
||||
|
||||
|
@ -155,7 +156,7 @@
|
|||
// filter (safesearch, time range or language) (this requires JavaScript
|
||||
// though)
|
||||
if (
|
||||
qinput !== null
|
||||
wasSearchBarFound
|
||||
&& searxng.settings.search_on_category_select
|
||||
// If .search_filters is undefined (invisible) we are on the homepage and
|
||||
// hence don't have to set any listeners
|
||||
|
@ -181,6 +182,17 @@
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
// shortcut to focus search bar
|
||||
if (wasSearchBarFound) {
|
||||
d.addEventListener('keyup', function (event) {
|
||||
if (event.key == "/") {
|
||||
const queryLength = qinput.value.length;
|
||||
qinput.setSelectionRange(queryLength, queryLength);
|
||||
qinput.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
})(window, document, window.searxng);
|
||||
|
|
Loading…
Add table
Reference in a new issue