fix(keybinding): release held shortcuts and modifiers when the screen locks or the PC sleeps

The lock desktop swallows keyup, so a hold-to-talk recording never ended,
the first shortcut after unlocking was dropped as auto-repeat, and Win from
Win+L made the next suggestion accept wait out the full 1.5s modifier timeout.
On powerMonitor lock-screen/suspend the chord machine now emits released for
emitted triggers and clears its state, and modifier tracking forgets held keys.
This commit is contained in:
Yun Chan 2026-10-21 00:28:40 +09:00
parent 8d003c8fca
commit 3e6cfd1ba8
6 changed files with 94 additions and 2 deletions

View file

@ -195,6 +195,17 @@ describe('ChordStateMachine — press / release', () => {
expect(events.map(label)).toEqual(['history-popup:pressed', 'history-popup:released'])
})
it('releaseAll sends released for held triggers and accepts the next press after a lost keyup', () => {
machine.setBindings([entry('history-popup', kb(0x56, { ctrl: true, shift: true }))])
const key = keyOf(0x56, { ctrl: true, shift: true })
machine.keyDown(key)
machine.releaseAll()
machine.keyDown(key)
expect(events.map(label)).toEqual(['history-popup:pressed', 'history-popup:released', 'history-popup:pressed'])
})
it('ignores keys that match no binding and releases nothing that was not pressed', () => {
machine.setBindings([entry('history-popup', kb(0x56, { ctrl: true, shift: true }))])
machine.keyDown(keyOf(0x41))