From d7a2f4a5151b2b5676e48d0465e25e0d1de009b7 Mon Sep 17 00:00:00 2001 From: Tiberiu Ichim Date: Sun, 22 Feb 2026 08:18:50 +0200 Subject: [PATCH] feat(ui): improve keyboard shortcuts discoverability and centralized management --- .../centralized_keyboard_shortcuts.md | 47 +++++++++++ artifacts/index.md | 1 + client/components/app/Appbar.vue | 81 +++++++++++-------- client/components/modals/ShortcutsModal.vue | 79 ++++++++++++++++++ client/components/ui/ContextMenuDropdown.vue | 9 ++- client/layouts/default.vue | 10 ++- client/pages/item/_id/index.vue | 5 +- client/plugins/constants.js | 36 ++++++++- client/store/globals.js | 4 + 9 files changed, 233 insertions(+), 39 deletions(-) create mode 100644 artifacts/2026-02-22/centralized_keyboard_shortcuts.md create mode 100644 client/components/modals/ShortcutsModal.vue diff --git a/artifacts/2026-02-22/centralized_keyboard_shortcuts.md b/artifacts/2026-02-22/centralized_keyboard_shortcuts.md new file mode 100644 index 000000000..290b90c19 --- /dev/null +++ b/artifacts/2026-02-22/centralized_keyboard_shortcuts.md @@ -0,0 +1,47 @@ +# 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 +1. **Extend `$hotkeys` in `client/plugins/constants.js`:** + Add a new section `App` or `Global` and `Batch` to store the exact combination of keys for each action. + Example: + ```javascript + 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: { + // ... + } + } + ``` + +2. **Refactor Event Listeners:** + Modify `handleKeyDown` in `Appbar.vue` and `keyDown` in `default.vue` to check against these constants instead of relying on hardcoded `e.key` checks. They can use the existing `this.getHotkeyName(e)` (which returns format `Ctrl-K` or `Alt-K`) from `default.vue`. + +3. **Refactor Visual Components:** + Components like `ContextMenuDropdown.vue` and `ShortcutsModal.vue` should import or use `this.$hotkeys` mapping to display the combination in the UI, rendering the exact combination so if it changes in `constants.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. diff --git a/artifacts/index.md b/artifacts/index.md index 68c48c0e4..80b5d462b 100644 --- a/artifacts/index.md +++ b/artifacts/index.md @@ -23,6 +23,7 @@ This index provides a quick reference for specification and documentation files | **2026-02-17** | [ui_enhancements.md](2026-02-17/ui_enhancements.md) | Specification for "View All" shortcuts on Home view shelves with specific sorting. | | **2026-02-20** | [promote_file_to_book.md](2026-02-20/promote_file_to_book.md) | Specification for "promoting" files from an existing book into a standalone library item, including a "Split Book" wizard. | | **2026-02-20** | [move_to_library_keyboard_shortcuts.md](2026-02-20/move_to_library_keyboard_shortcuts.md) | Specification for keyboard-shortcut-enabled library buttons in the "Move to Library" dialog. | +| **2026-02-22** | [centralized_keyboard_shortcuts.md](2026-02-22/centralized_keyboard_shortcuts.md) | Specification for centralizing keyboard shortcut definitions into a single configuration file. | | **General** | [docs/consolidate_feature.md](docs/consolidate_feature.md) | Comprehensive documentation for the "Consolidate" feature, including conflict resolution and technical details. | | **General** | [docs/item_restructuring_guide.md](docs/item_restructuring_guide.md) | Guide for Moving, Merging, and Splitting (Promoting) library items. | | **General** | [docs/metadata_management_tools.md](docs/metadata_management_tools.md) | Documentation for Reset Metadata and Batch Reset operations. | diff --git a/client/components/app/Appbar.vue b/client/components/app/Appbar.vue index 52b08cba4..205a6ae83 100644 --- a/client/components/app/Appbar.vue +++ b/client/components/app/Appbar.vue @@ -48,6 +48,12 @@ +
+ + keyboard + +
+