blockly > ShortcutRegistry > register
ShortcutRegistry.register() method
Registers a keyboard shortcut.
Signature:
register(shortcut: KeyboardShortcut, opt_allowOverrides?: boolean): void;
Parameters
Parameter |
Type |
Description |
shortcut |
KeyboardShortcut |
The shortcut for this key code. |
opt_allowOverrides |
boolean |
(Optional) True to prevent a warning when overriding an already registered item. |
Returns:
void
Exceptions
{Error} if a shortcut with the same name already exists.
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 2024-09-18 UTC.
[null,null,["Last updated 2024-09-18 UTC."],[[["The `ShortcutRegistry.register()` method is used to register keyboard shortcuts within a Blockly application."],["It accepts a `KeyboardShortcut` object defining the shortcut and an optional boolean to suppress warnings when overriding existing shortcuts."],["Attempting to register a shortcut with a name that already exists will throw an error."]]],["The `register` method within `ShortcutRegistry` registers keyboard shortcuts. It accepts a `KeyboardShortcut` object, representing the shortcut, and an optional boolean, `opt_allowOverrides`. If `opt_allowOverrides` is true, it prevents warnings when overriding existing shortcuts. The method returns nothing (void). An error is thrown if a shortcut with the same name is already registered and the `opt_allowOverrides` is not set to true.\n"]]