34 lines
843 B
TypeScript
34 lines
843 B
TypeScript
/**
|
|||
|
|
* `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);
|
||
|
|
}
|