1.8 KiB
Centralizing Keyboard Shortcuts
Date: 2026-02-22
Objective
Centralize the definitions of all keyboard shortcuts into a single configuration file (client/plugins/constants.js). Currently, hotkeys are scattered across various components (e.g., Appbar.vue, ContextMenuDropdown.vue, ShortcutsModal.vue), with hardcoded keys like Ctrl+K, Alt+H, etc.
Proposed Strategy
-
Extend
$hotkeysinclient/plugins/constants.js: Add a new sectionApporGlobalandBatchto store the exact combination of keys for each action. Example:const hotkeys = { // ... existings ones ... Global: { Home: 'Alt-H', Library: 'Alt-L', Series: 'Alt-S', Collections: 'Alt-C', Authors: 'Alt-A', ShortcutsHelper: 'Shift-/' }, Batch: { SelectAll: 'Ctrl-A', Consolidate: 'Ctrl-K', Merge: 'Ctrl-M', MoveToLibrary: 'Alt-M', ResetMetadata: 'Alt-R', QuickMatch: 'Alt-Q', Cancel: 'Escape' }, ItemView: { // ... } } -
Refactor Event Listeners: Modify
handleKeyDowninAppbar.vueandkeyDownindefault.vueto check against these constants instead of relying on hardcodede.keychecks. They can use the existingthis.getHotkeyName(e)(which returns formatCtrl-KorAlt-K) fromdefault.vue. -
Refactor Visual Components: Components like
ContextMenuDropdown.vueandShortcutsModal.vueshould import or usethis.$hotkeysmapping to display the combination in the UI, rendering the exact combination so if it changes inconstants.js, it updates automatically everywhere.
Expected Outcome
- Easier to manage and modify shortcuts in the future.
- Reduced risk of conflicts.
- A single source of truth for the codebase and documentation.