公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ui.root.setKeyHandler
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
为具有非预定义键的根面板设置 keydown 事件处理程序。当用户按下绑定的键命令时,处理程序仅触发一次。同一密钥将绑定到为其设置的最新处理程序。
用法 | 返回 |
---|
ui.root.setKeyHandler(keyCode, handler, description) | |
参数 | 类型 | 详细信息 |
---|
keyCode | List<ui.Key>|ui.Key | 键码或键码数组。例如,ui.Key.A 或 [ui.Key.SHIFT, ui.Key.A]。 |
handler | 函数 | 键命令的处理程序。 |
description | 字符串,可选 | 用于说明相应键命令的简短说明。说明将显示在快捷方式菜单中。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003esetKeyHandler\u003c/code\u003e enables assigning custom keyboard shortcuts to the root panel within a Google Workspace Add-on.\u003c/p\u003e\n"],["\u003cp\u003eIt accepts a key code (or array for combinations), a handler function to execute, and an optional description for the UI.\u003c/p\u003e\n"],["\u003cp\u003eOnly the most recently assigned handler for a specific key combination will be active, replacing any previous ones.\u003c/p\u003e\n"],["\u003cp\u003eThese custom shortcuts can be accessed and viewed by users within the add-on's Shortcuts Menu when a description is provided.\u003c/p\u003e\n"]]],["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"],null,["# ui.root.setKeyHandler\n\n\u003cbr /\u003e\n\nSets 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.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|------------------------------------------------------------|---------|\n| `ui.root.setKeyHandler(keyCode, handler, `*description*`)` | |\n\n| Argument | Type | Details |\n|---------------|------------------------|------------------------------------------------------------------------------------------------------------|\n| `keyCode` | List\\\u003cui.Key\\\u003e\\|ui.Key | A key code or an array of key codes. For example, ui.Key.A or \\[ui.Key.SHIFT, ui.Key.A\\]. |\n| `handler` | Function | The handler for the key command. |\n| `description` | String, optional | A short description that explains this key command. The description will be visible in the Shortcuts Menu. |"]]