mirror of
https://github.com/LukeSmithxyz/based.cooking.git
synced 2025-03-13 13:28:21 +00:00
add vim-like keybind to search
This commit is contained in:
parent
016effe3d8
commit
b8727deb0d
@ -23,6 +23,19 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const search = document.querySelector('#search')
|
||||
const clearSearch = document.querySelector('.clear-search')
|
||||
const artlist = document.getElementById('artlist')
|
||||
|
||||
document.addEventListener('keydown', function(e) {
|
||||
// if search already focused do nothing
|
||||
if (search === document.activeElement) return;
|
||||
|
||||
// if key pressed is '/'
|
||||
if (e.keyCode === 191) {
|
||||
search.focus();
|
||||
|
||||
// preventDefault so '/' is not added to search value
|
||||
e.preventDefault();
|
||||
}
|
||||
})
|
||||
|
||||
search.addEventListener('input', e => {
|
||||
// grab search input value
|
||||
|
Loading…
x
Reference in New Issue
Block a user