fix(calls): hotkey rebind denylist; ignore modifiers; keep Space on buttons

- useKeyBind refuses Tab/Enter/arrows/Home/End/Page*/Escape and bare
  modifier codes, and refuses a code equal to the other call key, with an
  inline message (isBindableCallKey, unit-tested).
- PTT and deafen handlers ignore events with Ctrl/Alt/Meta held (deafen
  also Shift), so Cmd+M / Ctrl+M no longer toggle deafen.
- PTT only preventDefault()s when the target is not an interactive
  control, so Space still activates focused buttons during a call.

Fixes #23

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
2026-09-12 14:48:34 -04:00
co-authored by Claude Opus 5
parent 6e4c4bc795
commit 2344c8273e
4 changed files with 129 additions and 9 deletions
+47
View File
@@ -0,0 +1,47 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { isBindableCallKey } from './callKeybind';
test('isBindableCallKey rejects navigation-critical codes', () => {
[
'Escape',
'Tab',
'Enter',
'NumpadEnter',
'ArrowUp',
'ArrowDown',
'ArrowLeft',
'ArrowRight',
'Home',
'End',
'PageUp',
'PageDown',
].forEach((code) => {
assert.equal(isBindableCallKey(code), false, `${code} should be unbindable`);
});
});
test('isBindableCallKey rejects bare modifier codes', () => {
[
'ShiftLeft',
'ShiftRight',
'ControlLeft',
'ControlRight',
'AltLeft',
'AltRight',
'MetaLeft',
'MetaRight',
].forEach((code) => {
assert.equal(isBindableCallKey(code), false, `${code} should be unbindable`);
});
});
test('isBindableCallKey accepts ordinary keys', () => {
['Space', 'KeyM', 'KeyQ', 'Digit1', 'F13'].forEach((code) => {
assert.equal(isBindableCallKey(code), true, `${code} should be bindable`);
});
});
test('isBindableCallKey rejects the empty string', () => {
assert.equal(isBindableCallKey(''), false);
});
+33
View File
@@ -0,0 +1,33 @@
/**
* `KeyboardEvent.code` values the push-to-talk / push-to-deafen rebind must
* never accept. Binding one of these turns it into a keyboard trap (the call
* hotkey listener swallows the key everywhere outside an editable field for
* the rest of the call) or collides with a bare modifier chord.
*/
const UNBINDABLE_CALL_KEY_CODES = new Set<string>([
'Escape',
'Tab',
'Enter',
'NumpadEnter',
'ArrowUp',
'ArrowDown',
'ArrowLeft',
'ArrowRight',
'Home',
'End',
'PageUp',
'PageDown',
'ShiftLeft',
'ShiftRight',
'ControlLeft',
'ControlRight',
'AltLeft',
'AltRight',
'MetaLeft',
'MetaRight',
]);
/** Whether `code` is safe to bind as a call hotkey (PTT / push-to-deafen). */
export function isBindableCallKey(code: string): boolean {
return code.length > 0 && !UNBINDABLE_CALL_KEY_CODES.has(code);
}