feat(useHotkey): port hotkey composable from Vuetify 3#66
Merged
johnleider merged 15 commits intomasterfrom Jan 5, 2026
Merged
feat(useHotkey): port hotkey composable from Vuetify 3#66johnleider merged 15 commits intomasterfrom
johnleider merged 15 commits intomasterfrom
Conversation
|
commit: |
Adds useHotkey composable for advanced keyboard shortcut handling: - Key combination support (ctrl+k, shift+enter, ctrl+shift+k) - Key sequence support (g-h for GitHub-style shortcuts) - Platform-aware modifiers (Mac: cmd→meta, others: cmd→ctrl) - Input focus detection (skip when typing in inputs) - Sequence timeout with automatic reset - Key alias normalization Includes colocated tests and exports parsing utilities for advanced usage. Closes leider-labs/knowledge#178
Align return interface with observer composables (useResizeObserver, useIntersectionObserver, etc.) for consistent API across the codebase. - Return object with isActive, isPaused, pause, resume, stop - isActive reflects whether listener is registered - isPaused reflects pause state - Cache isMac detection at module level - Move SSR guard into setup() for consistent return type
- Fix isModifier type guard to avoid unsafe assertion - Add documentation page for useHotkey composable - Add tests for three-key sequences - Add tests for console.warn on invalid inputs - Add tests for undefined keys handling (SSR-safe)
Add _platform parameter to enable testing Mac/non-Mac modifier mapping. Add tests for modifier-only hotkeys, platform-aware modifiers, and key alias integration through the full useHotkey flow.
Add tests for slash and underscore separators matching Vuetify 3. Add tests verifying timer cleanup on stop/pause mid-sequence. Document minus/hyphen aliases and alternative separators.
- Add ARIA role="textbox" and role="searchbox" detection - Discriminate input types (checkbox/radio allow hotkeys) - Remove internal utility re-exports (breaking change) - Add PlatformContext interface for type-safe testing - Add as const to keyAliasMap for better type inference - Add tests for new focus detection and edge cases
- Add ARIA roles combobox and spinbutton to isInputFocused() - Add date/time input types (date, datetime-local, time, month, week) - Make CombinationResult interface readonly - Remove redundant contentEditable check - Add tests for new ARIA roles and input types - Add sequential pause/resume/stop tests - Add accessibility notes to documentation
keyAliasMap and KeyAlias are internal implementation details.
Replace manual API documentation with auto-generated DocsApi. Fix import ordering after rebase.
1f8fed3 to
feed60c
Compare
useHotkey provides a superset of useKeydown functionality with key combinations, sequences, and platform-aware modifiers. - Remove useKeydown composable and tests - Update useSearch to use useHotkey - Update all docs, examples, and references
This reverts commit 7357570.
7798ab9 to
1546569
Compare
1546569 to
58b0ada
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
useHotkeycomposable from Vuetify 3 to@vuetify/v0ctrl+k,shift+enter,ctrl+shift+k)g-hfor GitHub-style shortcuts)Files Added
packages/0/src/composables/useHotkey/index.ts- Main composablepackages/0/src/composables/useHotkey/parsing.ts- Key combination/sequence parsingpackages/0/src/composables/useHotkey/aliases.ts- Key alias normalizationpackages/0/src/composables/useHotkey/index.test.ts- Colocated testsTest Plan
pnpm lintpassespnpm typecheckpassespnpm test:runpasses (32 new tests)Closes leider-labs/knowledge#178