From 45df8a878e14d4ee5631cfd288ba4028600acd60 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 10 Jun 2024 20:41:24 -0400 Subject: [PATCH] Use Record type for shortcut map too --- assets/js/shortcuts.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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