Stay organized with collections
Save and categorize content based on your preferences.
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.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-16 UTC."],[[["The `onKeyDown` method within the `ShortcutRegistry` class manages the 'key down' events in Blockly workspaces."],["It takes the workspace and the key down event as input, determining if a shortcut is triggered."],["The method returns `true` if the event was successfully handled by a registered shortcut, otherwise `false`."]]],[]]