Skip to content

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.

T

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.

true | undefined

true if a command returned a truthy value.

addEventListener("keydown", e => {
const handled = !!runHotkeys(e, map, data)
})