Skip to content

Add ignoreRepeat option to skip callback on held keys#1319

Open
nikoewe wants to merge 1 commit intoJohannesKlauss:mainfrom
nikoewe:feat/ignore-repeat-option
Open

Add ignoreRepeat option to skip callback on held keys#1319
nikoewe wants to merge 1 commit intoJohannesKlauss:mainfrom
nikoewe:feat/ignore-repeat-option

Conversation

@nikoewe
Copy link

@nikoewe nikoewe commented Feb 18, 2026

Summary

  • Adds a new ignoreRepeat option to Options that prevents the hotkey callback from firing repeatedly when a key is held down
  • Uses the native KeyboardEvent.repeat property to detect held keys and early-returns from the listener when ignoreRepeat is enabled

Usage

useHotkeys('a', () => {
  console.log('fires only once per key press')
}, { ignoreRepeat: true })

Test plan

  • Verify that with ignoreRepeat: true, holding a key only fires the callback once
  • Verify that without the option (or ignoreRepeat: false), the default repeat behavior is unchanged
  • Verify the option works alongside other options like keyup, keydown, and preventDefault

@vercel
Copy link

vercel bot commented Feb 18, 2026

@nikoewe is attempting to deploy a commit to the Johannes Klauss' projects Team on Vercel.

A member of the Team first needs to authorize it.

@JohannesKlauss
Copy link
Owner

Please add tests to this PR.

Uses KeyboardEvent.repeat to detect when a key is being held down
and skips the callback invocation when ignoreRepeat is enabled.
@nikoewe nikoewe force-pushed the feat/ignore-repeat-option branch from 113480e to 25cd546 Compare February 18, 2026 19:30
@nikoewe
Copy link
Author

nikoewe commented Feb 25, 2026

@JohannesKlauss Updated the tests!

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