跳至主要內容

KeyBindEvents.register

芒果凍布丁2025年5月17日小於 1 分鐘

Startup
@at startup
register(handler: (event: KeyBindEvent) => void):void

範例

@at startup
KeyBindEvents.register((event) => {
  // 創建按鍵綁定 (第一個參數為標識,按鍵觸發都會使用這個標識)
  event.create("create1", "key.test.create.1", -1, "key.group.debug");
  event.create("create2", "key.test.create.2", GLFW.GLFW_KEY_X, "key.group.debug")
    .addModifier(KeyModifier.ALT); // 添加修飾按鍵
});

方法

方法名稱回傳值說明
create(customName: string, keyNameKey: string, keyCode: number, keyGroupKey: string)KeyBindEvent$KeyBindBuilder創建按鍵綁定

create

創建按鍵綁定

create(customName: string, keyNameKey: string, keyCode: number, keyGroupKey: string): KeyBindEvent$KeyBindBuilder

參數

  • customName: string - 自定義的名稱
  • keyNameKey: string - 按鍵名稱的翻譯鍵
  • keyCode: number - 按鍵的鍵碼
  • keyGroupKey: string - 按鍵分組的翻譯鍵

回傳值

  • KeyBindEvent$KeyBindBuilder - KeyBindBuilder 的實例

KeyBindBuilder

方法名稱回傳值說明
addModifier(keyModifier: KeyModifier_)this添加修飾按鍵
getBuildKeyMapping()
get buildKeyMapping
KeyMapping獲取按鍵綁定的內部對象

addModifier

添加修飾按鍵

addModifier(keyModifier: KeyModifier_): this
參數
回傳值
  • this

貢獻者