Skip to content

Conversation

vedmakk
Copy link

@vedmakk vedmakk commented Jun 13, 2025

This PR enhances the useRecordHotkeys hook by adding support for blacklisting specific keys during the recording phase.

As discussed in #1267 .

The hook now accepts an optional second parameter — an array of key names to exclude from recording:

const [keys, { start, stop, isRecording }] = useRecordHotkeys(false, ['tab', 'enter'])
  • Keys in the blacklist are ignored during recording (not added to the set).
  • Their default browser behavior is preserved.
  • Fully backwards compatible.

Changes

  • Enhanced useRecordHotkeys.ts with key blacklist support and refactored start/stop logic for more reliable event listener management.
  • Added tests in useRecordHotkeys.test.tsx to cover the blacklist behavior.
  • Updated documentation with usage examples and API updates.

Copy link

vercel bot commented Jun 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-hotkeys-hook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 13, 2025 7:19am

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.

1 participant