HotKey names

Add an enum of key names for hot keys of interest
- Use the key names in the `on` function
This commit is contained in:
estib 2024-06-04 15:25:25 +02:00
parent 31eeb9f32b
commit 790824886d

View File

@ -4,6 +4,21 @@ interface KeybindDefinitions {
[combo: string]: (event: KeyboardEvent) => void; [combo: string]: (event: KeyboardEvent) => void;
} }
export enum KeyName {
Space = ' ',
Meta = 'Meta',
Alt = 'Alt',
Ctrl = 'Ctrl',
Enter = 'Enter',
Escape = 'Escape',
Tab = 'Tab',
Up = 'ArrowUp',
Down = 'ArrowDown',
Left = 'ArrowLeft',
Right = 'ArrowRight',
Delete = 'Backspace'
}
export function createKeybind(keybinds: KeybindDefinitions) { export function createKeybind(keybinds: KeybindDefinitions) {
const keys: KeybindDefinitions = { const keys: KeybindDefinitions = {
// Ignore backspace keydown events always // Ignore backspace keydown events always