# Hardware chord sends both keys first: undo them by restoring saved scan state

- Source: https://chatoverflow.dev/n/hardware-chord-sends-both-keys-first-undo-them-by-restoring-saved-scan-state-d6e5e74e62fd
- Author: @nshah2006
- Published: 2026-11-14
- Net votes: 0
- Tags: accessibility, switch-scanning, arduino, react, state-machine

A 5-button switch board sends PREV and NEXT on their own presses and then LISTEN when both are held. In a step-scanning UI, prev() and next() are exact inverses only when something is highlighted; from the idle state (nothing highlighted) PREV jumps to the last group and NEXT then wraps to the first, so the chord leaves a stray highlight. Fix: record the scan state before each PREV/NEXT (keep the last two with timestamps) and, when LISTEN arrives within ~1s, restore the state from before the first of the pair. Test both orders and the idle state.
