feat(keybinding): several shortcuts per action, mouse buttons, searchable picker

Shortcuts were defined in four places that drifted apart: per-action IPC channel
pairs, a hand-written VK table in the service, a second one in the renderer, and
three copies of the keycap styling. Adding an action meant editing all of them,
so two shortcuts stayed hardcoded in bootstrap and one had no settings entry at
all.

packages/core/src/keybinding.ts is now the single source for the binding type,
the selectable key catalog, the action catalog, normalization, validation,
conflict detection, display labels, search and deserialization. Main, preload
and renderer all read from it; nothing redefines keys or rules locally.

- Each action holds a list of bindings instead of one. AppConfig's four
  *Shortcut fields collapse into a single keyBindings map, migrated on launch.
- Mouse buttons can be bound. Left click is refused, right/middle need a
  modifier, side buttons are free. uiohook cannot swallow events, so the
  original click still fires and the UI says so.
- Keys can be picked from a grouped dropdown with a search box, not only by
  recording a keypress.
- HOTKEY's 14 channels become KEYBINDING's 9, taking the action as a parameter,
  so actions no longer multiply channels. The history and command popups moved
  out of bootstrap into ordinary actions.
- displayLabel is gone; labels derive from the binding and follow the app
  language and platform.

Fixes found on the way:
- Double-press hands-free was unreachable: lookup returned only the first
  matching action, and dictation shares its default binding.
- Reserved-combination checks compared joined key names, so a different modifier
  order let Ctrl+C through.
- Disabling shortcuts released every global registration in the process,
  including the popup ones, and never restored them.
- Enabling shortcuts after starting disabled left nothing registered.
- The dashboard stored the caption event payload instead of the state in it.
This commit is contained in:
Yun Chan 2026-09-21 13:41:47 +09:00
parent 0ca9e242fa
commit 4ad1ae6ed4
49 changed files with 5901 additions and 1792 deletions

View file

@ -270,5 +270,60 @@
"mobile.works.historyDescription": "ค้นหาและจัดการบทถอดความจากการบันทึกเสียงและการนำเข้า",
"mobile.meetings.templateEmpty": "ไม่มีเทมเพลตเอกสารประชุมที่ใช้ได้ เริ่มประชุมโดยไม่ใช้เทมเพลตได้",
"mobile.meetings.templateNone": "เริ่มโดยไม่ใช้เทมเพลต",
"mobile.meetings.templateNoneDesc": "เลือกเทมเพลตภายหลังเมื่อสร้างเอกสาร"
"mobile.meetings.templateNoneDesc": "เลือกเทมเพลตภายหลังเมื่อสร้างเอกสาร",
"keybinding.mouse.left": "ปุ่มซ้ายของเมาส์",
"keybinding.mouse.right": "ปุ่มขวาของเมาส์",
"keybinding.mouse.middle": "ปุ่มกลางของเมาส์",
"keybinding.mouse.back": "ปุ่มย้อนกลับของเมาส์",
"keybinding.mouse.forward": "ปุ่มไปข้างหน้าของเมาส์",
"keybinding.group.mouse": "เมาส์",
"keybinding.group.modifier": "ปุ่มปรับแต่ง",
"keybinding.group.function": "ปุ่มฟังก์ชัน",
"keybinding.group.letter": "ตัวอักษร",
"keybinding.group.digit": "ตัวเลข",
"keybinding.group.numpad": "แป้นตัวเลข",
"keybinding.group.navigation": "การนำทาง",
"keybinding.group.editing": "การแก้ไข",
"keybinding.group.punctuation": "สัญลักษณ์",
"keybinding.group.system": "ระบบ",
"keybinding.action.dictation": "การบอกเล่า",
"keybinding.action.dictation.desc": "บันทึกเสียงขณะที่กดปุ่มค้างไว้",
"keybinding.action.handsFree": "โหมดสัมผัสเดียว",
"keybinding.action.handsFree.desc": "กดสองครั้งเพื่อเปิดหรือปิด",
"keybinding.action.command": "คำสั่งเสียง",
"keybinding.action.command.desc": "สั่งงานด้วยเสียง",
"keybinding.action.caption": "คำบรรยายสด",
"keybinding.action.caption.desc": "เปิดหรือปิดคำบรรยายสด",
"keybinding.action.historyPopup": "ป๊อปอัปประวัติ",
"keybinding.action.historyPopup.desc": "เปิดป๊อปอัปประวัติ",
"keybinding.action.commandPopup": "ป๊อปอัปคำสั่ง",
"keybinding.action.commandPopup.desc": "เปิดป๊อปอัปคำสั่ง",
"keybinding.reject.unknownKey": "ไม่รองรับปุ่มนี้",
"keybinding.reject.systemReserved": "เป็นปุ่มลัดที่ระบบสงวนไว้",
"keybinding.reject.modifierRequired": "ต้องใช้ร่วมกับปุ่มปรับแต่ง (Ctrl/Alt/Shift)",
"keybinding.disabled.mouseLeft": "คลิกซ้ายถูกใช้กับการควบคุมหน้าจอทั้งหมด จึงกำหนดเป็นปุ่มลัดไม่ได้",
"keybinding.warning.mousePassthrough": "ปุ่มเมาส์จะยังทำงานตามการทำงานเดิมไปพร้อมกันด้วย",
"keybinding.ui.add": "เพิ่ม",
"keybinding.ui.remove": "ลบ",
"keybinding.ui.reset": "คืนค่าเริ่มต้น",
"keybinding.ui.tabRecord": "กดปุ่มเอง",
"keybinding.ui.tabList": "เลือกจากรายการ",
"keybinding.ui.search": "ค้นหาปุ่ม",
"keybinding.ui.searchEmpty": "ไม่พบผลการค้นหา",
"keybinding.ui.pressKeys": "กดปุ่มหรือปุ่มเมาส์ที่ต้องการ",
"keybinding.ui.noBindings": "ยังไม่ได้ตั้งปุ่มลัด",
"keybinding.ui.conflictWith": "ซ้ำกับ {{action}}",
"keybinding.ui.modifiers": "ปุ่มปรับแต่ง",
"keybinding.ui.selectedKey": "ปุ่มที่เลือก",
"keybinding.ui.sectionVoice": "เสียง",
"keybinding.ui.sectionWindow": "หน้าต่าง / ป๊อปอัป",
"keybinding.ui.duplicate": "เพิ่มปุ่มลัดนี้ไว้แล้ว",
"keybinding.ui.holdMode": "กดค้าง",
"keybinding.ui.doublePress": "กดสองครั้ง",
"keybinding.ui.pickerTitle": "การตั้งค่าปุ่มลัด",
"keybinding.ui.pressToRecord": "กดเพื่อเริ่มบันทึก",
"keybinding.ui.recordHint": "กรอกปุ่มลัด (เช่น: Ctrl+Shift+Q) หรือปุ่มเดี่ยว (เช่น: F5)",
"keybinding.ui.recordAgain": "กรอกใหม่",
"keybinding.ui.saveFailed": "บันทึกปุ่มลัดไม่สำเร็จ",
"keybinding.ui.globalEnabled": "ใช้ปุ่มลัดส่วนกลาง"
}