keyboard handlers: layout agnostic keycodes

This commit is contained in:
He4eT 2024-01-19 18:44:46 +01:00
commit 8d344c865e

View file

@ -1,19 +1,19 @@
export const attachKeyboardHandlers = (store) => { export const attachKeyboardHandlers = (store) => {
document.addEventListener('keydown', (e) => { document.addEventListener('keydown', (e) => {
switch (e.key) { switch (e.code) {
case 'd': case 'KeyD':
case 'ArrowLeft': case 'ArrowLeft':
store.actions.closeTab(store.getCurrentState().currentTab) store.actions.closeTab(store.getCurrentState().currentTab)
return return
case 'k': case 'KeyK':
case 'ArrowRight': case 'ArrowRight':
store.actions.keepTab(store.getCurrentState().currentTab) store.actions.keepTab(store.getCurrentState().currentTab)
return return
case 'f': case 'KeyF':
case 'ArrowUp': case 'ArrowUp':
store.actions.goToTab(store.getCurrentState().currentTab) store.actions.goToTab(store.getCurrentState().currentTab)
return return
case 'r': case 'KeyR':
location.reload() location.reload()
return return
} }