Repository navigation
feat: Config.inferKeyRepeat for devices that never set KeyboardEvent.repeat - #80
Merged
Merged
Conversation
…repeat Some devices send a stream of repeat=false key-downs while a key is held, and a single key-up on release. useHold saw each as a new press, so a hold never fired, and the hold latch was lifted by what looked like a fresh press. With Config.inferKeyRepeat set (ms), the focus manager marks a key-down as a repeat when the same key sent a key-down within the window with no key-up in between. The window runs from the previous key-down, so a missed key-up cannot wedge a key. Off by default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
Some devices never set
KeyboardEvent.repeat. Holding a key sends a stream ofrepeat=falsekey-downs and a single key-up on release:Two things break:
useHoldtreats each key-down as a new press, so the hold timer keeps restarting.onHoldnever fires, and the release resolves as a tap.onHoldfocused.An app-level workaround (rewrite repeated key-downs as
repeat: trueuntil key-up) disables the key permanently if a key-up is ever missed.Change
New opt-in
Config.inferKeyRepeat(ms, off by default). When it's set, the focus manager marks a key-down as a repeat when the same key sent a key-down less than that long ago with no key-up in between. It overwritesrepeaton the event souseHold, the suppression latch and app handlers all read the same value.Unidentified) still ends the press.useHoldis unchanged.Off by default because on a key that never sends key-up (webOS OK), a second tap inside the window would be read as a repeat. Enable it per device.
Tests
8 new cases in
tests/keySuppression.test.tsx, including an end-to-enduseHoldhold on the device's key pattern. That test fails with inference off (onHoldnever called). Full suite, lint andtscpass.Not yet verified on the physical device.
🤖 Generated with Claude Code