runHotkeys
runHotkeys<
T>(e,map,data):true|undefined
Defined in: extensions/commands/utils.ts:96
Utility that runs all commands whose key matches the keyboard event until a command
returns a truthy value. In that case preventDefault and stopImmediatePropagation
are called.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”KeyboardEvent
Keyboard event to run commands for.
HotkeyMap<T>
Record mapping keys to a list of commands for that key.
T
Argument to pass to the commands.
Returns
Section titled “Returns”true | undefined
true if a command returned a truthy value.
Example
Section titled “Example”addEventListener("keydown", e => { const handled = !!runHotkeys(e, map, data)})