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": "Tìm kiếm và quản lý bản chép lời từ bản ghi và tệp nhập.",
"mobile.meetings.templateEmpty": "Không có mẫu tài liệu họp nào. Bạn có thể bắt đầu cuộc họp mà không cần mẫu.",
"mobile.meetings.templateNone": "Bắt đầu không cần mẫu",
"mobile.meetings.templateNoneDesc": "Chọn mẫu sau khi khi tạo tài liệu"
"mobile.meetings.templateNoneDesc": "Chọn mẫu sau khi khi tạo tài liệu",
"keybinding.mouse.left": "Chuột trái",
"keybinding.mouse.right": "Chuột phải",
"keybinding.mouse.middle": "Chuột giữa",
"keybinding.mouse.back": "Nút Lùi của chuột",
"keybinding.mouse.forward": "Nút Tiến của chuột",
"keybinding.group.mouse": "Chuột",
"keybinding.group.modifier": "Phím bổ trợ",
"keybinding.group.function": "Phím chức năng",
"keybinding.group.letter": "Chữ cái",
"keybinding.group.digit": "Chữ số",
"keybinding.group.numpad": "Bàn phím số",
"keybinding.group.navigation": "Điều hướng",
"keybinding.group.editing": "Chỉnh sửa",
"keybinding.group.punctuation": "Ký hiệu",
"keybinding.group.system": "Hệ thống",
"keybinding.action.dictation": "Chính tả",
"keybinding.action.dictation.desc": "Ghi âm trong khi giữ phím.",
"keybinding.action.handsFree": "Chế độ một chạm",
"keybinding.action.handsFree.desc": "Nhấn hai lần để bật hoặc tắt.",
"keybinding.action.command": "Lệnh thoại",
"keybinding.action.command.desc": "Thực hiện lệnh bằng giọng nói.",
"keybinding.action.caption": "Phụ đề trực tiếp",
"keybinding.action.caption.desc": "Bật hoặc tắt phụ đề trực tiếp.",
"keybinding.action.historyPopup": "Cửa sổ lịch sử",
"keybinding.action.historyPopup.desc": "Mở cửa sổ bật lên lịch sử.",
"keybinding.action.commandPopup": "Cửa sổ lệnh",
"keybinding.action.commandPopup.desc": "Mở cửa sổ bật lên lệnh.",
"keybinding.reject.unknownKey": "Phím này không được hỗ trợ",
"keybinding.reject.systemReserved": "Đây là phím tắt dành riêng cho hệ thống",
"keybinding.reject.modifierRequired": "Phải kết hợp với phím bổ trợ (Ctrl/Alt/Shift)",
"keybinding.disabled.mouseLeft": "Nhấp chuột trái được dùng cho mọi thao tác trên màn hình nên không thể gán",
"keybinding.warning.mousePassthrough": "Các nút chuột vẫn đồng thời thực hiện hành động gốc của chúng",
"keybinding.ui.add": "Thêm",
"keybinding.ui.remove": "Xóa",
"keybinding.ui.reset": "Khôi phục mặc định",
"keybinding.ui.tabRecord": "Nhấn phím",
"keybinding.ui.tabList": "Chọn từ danh sách",
"keybinding.ui.search": "Tìm phím",
"keybinding.ui.searchEmpty": "Không có kết quả tìm kiếm",
"keybinding.ui.pressKeys": "Hãy nhấn phím hoặc nút chuột bạn muốn",
"keybinding.ui.noBindings": "Chưa đặt phím tắt",
"keybinding.ui.conflictWith": "Trùng với {{action}}",
"keybinding.ui.modifiers": "Phím bổ trợ",
"keybinding.ui.selectedKey": "Phím đã chọn",
"keybinding.ui.sectionVoice": "Giọng nói",
"keybinding.ui.sectionWindow": "Cửa sổ / Cửa sổ bật lên",
"keybinding.ui.duplicate": "Phím tắt này đã được thêm",
"keybinding.ui.holdMode": "Giữ phím",
"keybinding.ui.doublePress": "Nhấn hai lần",
"keybinding.ui.pickerTitle": "Cài đặt phím tắt",
"keybinding.ui.pressToRecord": "Nhấn để bắt đầu ghi âm",
"keybinding.ui.recordHint": "Nhập tổ hợp phím (ví dụ: Ctrl+Shift+Q) hoặc phím đơn (ví dụ: F5)",
"keybinding.ui.recordAgain": "Nhập lại",
"keybinding.ui.saveFailed": "Không thể lưu phím tắt",
"keybinding.ui.globalEnabled": "Bật phím tắt toàn cục"
}