Ignore a keydown that carries no key
Picking a saved login from Chrome's password autofill dispatches a plain Event named "keydown", with no key on it. The shortcut listener passed it to comboOf, which read the key's length and threw -- an uncaught TypeError in the console on every sign-in. Harmless, since nothing was bound to it, but it was noise that looks like a real fault. comboOf now returns null for an event with no key, as it already does for a bare modifier, so the listener stops there.
This commit is contained in:
@@ -136,6 +136,10 @@ const isMac = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigat
|
||||
|
||||
export function comboOf(e: KeyboardEvent): string | null {
|
||||
const key = e.key;
|
||||
// Chrome's password autofill dispatches a plain Event named "keydown" when a
|
||||
// saved login is picked: no key, nothing to match, and reading its length
|
||||
// threw on every sign-in.
|
||||
if (!key) return null;
|
||||
if (key === "Shift" || key === "Control" || key === "Alt" || key === "Meta") return null;
|
||||
const parts: string[] = [];
|
||||
const mod = isMac ? e.metaKey : e.ctrlKey;
|
||||
|
||||
Reference in New Issue
Block a user