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($event: KeyboardEvent, context: KeymapContext): boolean

Parameters:

ParameterTypeDescription
$eventKeyboardEvent
contextKeymapContextThe keymap context.

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