使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
blockly > ShortcutRegistry > KeyboardShortcut
ShortcutRegistry.KeyboardShortcut 接口
用于定义键盘快捷键的接口。
Signature:
interface KeyboardShortcut
属性
属性 |
修饰符 |
类型 |
说明 |
allowCollision? |
|
布尔值 |
(可选)绑定此快捷方式的 .keyCodes (如果有)时要传递给 addKeyMapping 的 allowCollision 的值。 注意:这仅用于在首次注册此快捷方式时绑定按键代码,而不用于任何随后恰好引用此快捷方式名称的 addKeyMapping 调用。 |
callback? |
|
(workspace: WorkspaceSvg, e: Event, shortcut: KeyboardShortcut, scope: Scope) => boolean |
(可选)在调用快捷方式时要调用的函数。 |
keyCodes? |
|
(number | string)[] |
(可选)要绑定(通过 ShortcutRegistry.prototype.addKeyMapping)到此快捷方式的可选按键代码列表。 |
元数据? |
|
对象 |
(可选)可选的附加到快捷方式的任意额外数据。 |
name |
|
字符串 |
快捷方式的名称。应是唯一的。 |
preconditionFn? |
|
(workspace: WorkspaceSvg, scope: Scope) => boolean |
(可选)在调用快捷方式时(在调用 callback 之前)调用的函数,用于确定此快捷方式是否适用于当前情况。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[],["The `KeyboardShortcut` interface defines properties for keyboard shortcuts. It includes a mandatory `name` (string) and several optional properties: `allowCollision` (boolean) to manage shortcut conflicts, `callback` (function) for the action to perform, `keyCodes` (array) specifying the keyboard input, `metadata` (object) for extra data, and `preconditionFn` (function) for a condition that must be met before the shortcut is used. The `callback` and `preconditionFn` are functions that receive a `WorkspaceSvg` object as an input.\n"]]