文档
类型
KeyBindingValue

KeyBindingValue

KeyBindingValue 是一个联合类型,用于表示与某个 KeyBindingType 关联的按键。

type KeyBindingValue = WebKeyboardKey[] | WebKeyboardKey | null;
  • WebKeyboardKeystring 的别名(大小写不敏感)。可用值请参见 MDN key values (opens in a new tab)
  • null 表示 无绑定(在重新绑定前该动作将无法触发)。

示例

单按键

game.keyMap.setKeyBinding(KeyBindingType.skipAction, " "); // 空格键

多按键

game.keyMap.setKeyBinding(KeyBindingType.skipAction, ["Control", "F3"]);

移除绑定

game.keyMap.setKeyBinding(KeyBindingType.skipAction, null);

参见:KeyBindingTypeKeyMap