blockly > ShortcutRegistry > onKeyDown
ShortcutRegistry.onKeyDown() method
Handles key down events.
- Any
KeyboardShortcut(s) mapped to the keycodes that cause eventeto be fired will be processed, in order from least- to most-recently registered. - If the shortcut'spreconditionFnexists it will be called. IfpreconditionFnreturns false the shortcut'scallbackfunction will be skipped. Processing will continue with the next shortcut, if any. - The shortcut'scallbackfunction will then be called. If it returns true, processing will terminate andonKeyDownwill 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,onKeyDownwill 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.