popup/tabswiper: extract keyboard handlers

This commit is contained in:
He4eT 2023-08-17 04:10:15 +03:00
commit bf02902beb

View file

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