blockly > ShortcutRegistry > onKeyDown

ShortcutRegistry.onKeyDown() method

Handles key down events.

  • Any KeyboardShortcut(s) mapped to the keycodes that cause event e to be fired will be processed, in order from least- to most-recently registered. - If the shortcut's preconditionFn exists it will be called. If preconditionFn returns false the shortcut's callback function will be skipped. Processing will continue with the next shortcut, if any. - The shortcut's callback function will then be called. If it returns true, processing will terminate and onKeyDown 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.