ui.root.setKeyHandler
Sets a keydown event handler to the root panel with a non-predefined key. The handler is fired only once when a user presses the bound key command. The same key will be bound to the latest handler set to it.
Usage | Returns |
---|
ui.root.setKeyHandler(keyCode, handler, description) | |
Argument | Type | Details |
---|
keyCode | List | A key code or an array of key codes. For example, ui.Key.A or [ui.Key.SHIFT, ui.Key.A]. |
handler | Function | The handler for the key command. |
description | String, optional | A short description that explains this key command. The description will be visible in the Shortcuts Menu. |
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 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[[["`setKeyHandler` enables assigning custom keyboard shortcuts to the root panel within a Google Workspace Add-on."],["It accepts a key code (or array for combinations), a handler function to execute, and an optional description for the UI."],["Only the most recently assigned handler for a specific key combination will be active, replacing any previous ones."],["These custom shortcuts can be accessed and viewed by users within the add-on's Shortcuts Menu when a description is provided."]]],["The `setKeyHandler` function binds a key command to a handler function on the root panel. It accepts a key code (or array of codes), a handler function, and an optional description. When the bound key is pressed, the handler is executed once. Only the most recently assigned handler for a specific key will be triggered. Key codes can be individual (e.g., `ui.Key.A`) or combined (e.g., `[ui.Key.SHIFT, ui.Key.A]`). The description is used in the Shortcuts Menu.\n"]]