From eb2ea8df1de2aaaab8a1ed069b34ca7385e30af2 Mon Sep 17 00:00:00 2001 From: Andray Date: Sat, 16 Mar 2024 17:42:25 +0400 Subject: [PATCH] check e.key in up event --- .../canvas-zoom-and-pan/javascript/zoom.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js index a575862df..dfd7b17a2 100644 --- a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js +++ b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js @@ -841,24 +841,24 @@ onUiLoaded(async() => { // Prevent firefox to open toolbar on pressing alt - let isAltPressed = false; + let wasAltPressed = false; function handleAltKeyDown(e) { if (!activeElement) return; if (hotkeysConfig.canvas_hotkey_zoom !== "Alt") return; if (e.code === "AltLeft" || e.code === "AltRight") { - isAltPressed = true; + wasAltPressed = true; } else { - isAltPressed = false; + wasAltPressed = false; } } function handleAltKeyUp(e) { if (hotkeysConfig.canvas_hotkey_zoom !== "Alt") return; - if (isAltPressed) { + if (wasAltPressed || (activeElement && e.key === "Alt")) { e.preventDefault(); } - isAltPressed = false; + wasAltPressed = false; } document.addEventListener("keydown", handleAltKeyDown);