mirror of
https://github.com/He4eT/tabswiper.git
synced 2026-05-05 00:57:23 +00:00
popup/tabswiper: extract keyboard handlers
This commit is contained in:
parent
3257dc3cab
commit
bf02902beb
1 changed files with 21 additions and 0 deletions
21
popup/tabswiper/modules/keyboardHandlers.js
Normal file
21
popup/tabswiper/modules/keyboardHandlers.js
Normal 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
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue