Skip to content

KeyboardCommand.onKey method

KeyboardCommand › onKey

The handler invoked when the shortcut is pressed. When omitted, the command is a hint only and no scope handler is registered.

Signature:

onKey(evt: KeyboardEvent, ctx: KeymapContext): boolean

Parameters:

ParameterTypeDescription
evtKeyboardEventThe keyboard event.
ctxKeymapContextThe keymap context.

Returns: booleanfalse to prevent Obsidian's default handling, or void/true otherwise.