function createHotkeyHandler(
hotkey,
callback,
options): (event) => void;
Defined in: match.ts:122
Creates a keyboard event handler that calls the callback when the hotkey matches.
The hotkey string or ParsedHotkey to match
The function to call when the hotkey matches
CreateHotkeyHandlerOptions = {}
Options for matching and handling
A function that can be used as an event handler
(event): void;
KeyboardEvent
void
const handler = createHotkeyHandler('Mod+S', (event, { hotkey, parsedHotkey }) => {
console.log(`${hotkey} was pressed`)
handleSave()
})
document.addEventListener('keydown', handler)