From 6f51e0555376cff9f185cb4f1dde8537bfec92af Mon Sep 17 00:00:00 2001 From: Andray Date: Fri, 15 Mar 2024 12:01:43 +0400 Subject: [PATCH] prevent alt menu for firefox --- .../canvas-zoom-and-pan/javascript/zoom.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js index 64e7a638a..aa27ac157 100644 --- a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js +++ b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js @@ -966,3 +966,26 @@ onUiLoaded(async() => { // Add integration with Inpaint Anything // applyZoomAndPanIntegration("None", ["#ia_sam_image", "#ia_sel_mask"]); }); + + +onUiLoaded(function() { + let isAltPressed = false; + + function handleAltKeyDown(e) { + if (e.code === "AltLeft" || e.code === "AltRight") { + isAltPressed = true; + } else { + isAltPressed = false; + } + } + + function handleAltKeyUp(e) { + if (isAltPressed) { + e.preventDefault(); + } + isAltPressed = false; + } + + document.addEventListener("keydown", handleAltKeyDown); + document.addEventListener("keyup", handleAltKeyUp); +});