From 50f3882b3ea0c38a9eecc6852aae191bd9d6d87f Mon Sep 17 00:00:00 2001 From: Pax1601 Date: Tue, 18 Mar 2025 13:02:12 +0100 Subject: [PATCH] fix: "Alt" keybinds getting stuck when switching windows with alt+tab --- frontend/react/src/shortcut/shortcut.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/react/src/shortcut/shortcut.ts b/frontend/react/src/shortcut/shortcut.ts index 39b0d951..3949286e 100644 --- a/frontend/react/src/shortcut/shortcut.ts +++ b/frontend/react/src/shortcut/shortcut.ts @@ -21,7 +21,7 @@ export class Shortcut { ModalEvent.on((modal) => (this.#modal = modal)); /* On keyup, it is enough to check the code only, not the entire combination */ - document.addEventListener("keyup", (ev: any) => { + window.addEventListener("keyup", (ev: any) => { if (this.#modal) return; if (this.#keydown && this.getOptions().code === ev.code) { console.log(`Keyup for shortcut ${this.#id}`); @@ -32,7 +32,7 @@ export class Shortcut { }); /* Forced keyup, in case the window loses focus */ - document.addEventListener("blur", (ev: any) => { + window.addEventListener("blur", (ev: any) => { if (this.#keydown) { console.log(`Keyup (forced by blur) for shortcut ${this.#id}`); ev.preventDefault(); @@ -42,7 +42,7 @@ export class Shortcut { }); /* On keydown, check exactly if the requested key combination is being pressed */ - document.addEventListener("keydown", (ev: any) => { + window.addEventListener("keydown", (ev: any) => { if (this.#modal) return; if ( !(this.#keydown || keyEventWasInInput(ev) || this.getOptions().code !== ev.code) &&