Repository navigation
Let apps consume a switch press with interceptPress - #4
Conversation
- useKeyboardSwitches calls interceptPress when a switch goes down; returning true consumes the press and its release without a scan action, so an app can let any press stop a repeat - Test, document, and bump to 0.4.0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
| if (!gestures.isHeld() && latest.current.interceptPress?.(match.id)) { | ||
| intercepted.add(event.code); | ||
| return; |
There was a problem hiding this comment.
Overlapping switches trigger scan actions
An intercepted switch never enters gestures, so gestures.isHeld() stays false while that switch is still down. When interceptPress stops repeating movement and returns false on later calls, pressing a second switch during that hold starts a new gesture. Releasing it can select an item or move the scan, instead of being ignored like other overlapping presses. The callback also runs while another switch is held.
Before merging, track intercepted switches as held without assigning them a scan action, and add a test for overlapping presses.
Artifacts
- The preserved authored test exercised real DOM key events through the hook and dispatcher, confirming the overlapping-switch regression.
- The preserved base execution output includes its command, working directory, and exit code, showing that overlapping Enter release caused no action.
- The preserved HEAD execution output includes its command, working directory, and exit code, showing next dispatch while Space remained down.
Ran code and verified through T-Rex
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/dom/keyboardSwitches.ts
Line: 108-110
Comment:
**Overlapping switches trigger scan actions**
An intercepted switch never enters `gestures`, so `gestures.isHeld()` stays false while that switch is still down. When `interceptPress` stops repeating movement and returns false on later calls, pressing a second switch during that hold starts a new gesture. Releasing it can select an item or move the scan, instead of being ignored like other overlapping presses. The callback also runs while another switch is held.
Before merging, track intercepted switches as held without assigning them a scan action, and add a test for overlapping presses.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Switchify Remote needs any switch press to stop a repeating pointer movement, as Switchify Android does, instead of moving the scan.
useKeyboardSwitches({ interceptPress })is called when a switch goes down and no other switch is held. Returning true consumes that press and its release, and no scan action follows.Validation
npm test: 63 tests pass.npm run lintis clean.🤖 Generated with Claude Code