Use Record type for shortcut map too

This commit is contained in:
Liam 2024-06-10 20:41:24 -04:00
parent 6ffa24b4b8
commit 45df8a878e

View file

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