Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

feat(useHotkey): port hotkey composable from Vuetify 3#66

Merged
johnleider merged 15 commits intomasterfrom
feat/use-hotkey
Jan 5, 2026
Merged

feat(useHotkey): port hotkey composable from Vuetify 3#66
johnleider merged 15 commits intomasterfrom
feat/use-hotkey

Conversation

@johnleider
Copy link
Member

Summary

  • Ports useHotkey composable from Vuetify 3 to @vuetify/v0
  • Adds key combination support (ctrl+k, shift+enter, ctrl+shift+k)
  • Adds 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

Files Added

  • packages/0/src/composables/useHotkey/index.ts - Main composable
  • packages/0/src/composables/useHotkey/parsing.ts - Key combination/sequence parsing
  • packages/0/src/composables/useHotkey/aliases.ts - Key alias normalization
  • packages/0/src/composables/useHotkey/index.test.ts - Colocated tests

Test Plan

  • pnpm lint passes
  • pnpm typecheck passes
  • pnpm test:run passes (32 new tests)

Closes leider-labs/knowledge#178

Copilot AI review requested due to automatic review settings December 18, 2025 17:55
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 18, 2025

Open in StackBlitz

commit: 58b0ada

This comment was marked as spam.

@johnleider johnleider added this to the v0.1.0 milestone Jan 1, 2026
@vuetifyjs vuetifyjs deleted a comment from Copilot AI Jan 5, 2026
@vuetifyjs vuetifyjs deleted a comment from Copilot AI Jan 5, 2026
@vuetifyjs vuetifyjs deleted a comment from Copilot AI Jan 5, 2026
@vuetifyjs vuetifyjs deleted a comment from Copilot AI Jan 5, 2026
@vuetifyjs vuetifyjs deleted a comment from Copilot AI Jan 5, 2026
@vuetifyjs vuetifyjs deleted a comment from Copilot AI Jan 5, 2026
@vuetifyjs vuetifyjs deleted a comment from Copilot AI Jan 5, 2026
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.
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
@vuetifyjs vuetifyjs deleted a comment from Copilot AI Jan 5, 2026
@vuetifyjs vuetifyjs deleted a comment from Copilot AI Jan 5, 2026
@vuetifyjs vuetifyjs deleted a comment from Copilot AI Jan 5, 2026
@vuetifyjs vuetifyjs deleted a comment from Copilot AI Jan 5, 2026
@johnleider johnleider merged commit c8f28dc into master Jan 5, 2026
10 of 11 checks passed
@johnleider johnleider deleted the feat/use-hotkey branch January 5, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants