blockly > ShortcutRegistry > onKeyDown
ShortcutRegistry.onKeyDown() method
Handles key down events.
- Any
KeyboardShortcut
(s) mapped to the keycodes that cause evente
to be fired will be processed, in order from least- to most-recently registered. - If the shortcut'spreconditionFn
exists it will be called. IfpreconditionFn
returns false the shortcut'scallback
function will be skipped. Processing will continue with the next shortcut, if any. - The shortcut'scallback
function will then be called. If it returns true, processing will terminate andonKeyDown
will return true. If it returns false, processing will continue with with the next shortcut, if any. - If all registered shortcuts for the given keycode have been processed without any having returned true,onKeyDown
will return false.
Signature:
onKeyDown(workspace: WorkspaceSvg, e: KeyboardEvent): boolean;
Parameters
Parameter | Type | Description |
---|---|---|
workspace | WorkspaceSvg | The main workspace where the event was captured. |
e | KeyboardEvent | The key down event. |
Returns:
boolean
True if the event was handled, false otherwise.