diff --git a/assets/js/shortcuts.ts b/assets/js/shortcuts.ts index a3254c16..d47da985 100644 --- a/assets/js/shortcuts.ts +++ b/assets/js/shortcuts.ts @@ -4,9 +4,7 @@ import { $ } from './utils/dom'; -interface ShortcutKeycodes { - [key: string]: () => void -} +type ShortcutKeyMap = Record void>; function getHover(): string | null { const thumbBoxHover = $('.media-box:hover'); @@ -45,7 +43,7 @@ function isOK(event: KeyboardEvent): boolean { document.activeElement.tagName !== 'TEXTAREA'; } -const keyCodes: ShortcutKeycodes = { +const keyCodes: ShortcutKeyMap = { KeyJ() { click('.js-prev'); }, // J - go to previous image KeyI() { click('.js-up'); }, // I - go to index page KeyK() { click('.js-next'); }, // K - go to next image