Skip to content

Commit

Permalink
Merge pull request #15267 from light-and-ray/prevent_alt_menu_on_firefox
Browse files Browse the repository at this point in the history
prevent alt menu for firefox
  • Loading branch information
AUTOMATIC1111 authored Mar 16, 2024
2 parents 874809e + 7598a92 commit 2f9d1c3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,32 @@ onUiLoaded(async() => {
document.addEventListener("keydown", handleMoveKeyDown);
document.addEventListener("keyup", handleMoveKeyUp);


// Prevent firefox to open toolbar on pressing alt
let wasAltPressed = false;

function handleAltKeyDown(e) {
if (!activeElement) return;
if (hotkeysConfig.canvas_hotkey_zoom !== "Alt") return;
if (e.key === "Alt") {
wasAltPressed = true;
} else {
wasAltPressed = false;
}
}

function handleAltKeyUp(e) {
if (hotkeysConfig.canvas_hotkey_zoom !== "Alt") return;
if (wasAltPressed || (activeElement && e.key === "Alt")) {
e.preventDefault();
}
wasAltPressed = false;
}

document.addEventListener("keydown", handleAltKeyDown);
document.addEventListener("keyup", handleAltKeyUp);


// Detect zoom level and update the pan speed.
function updatePanPosition(movementX, movementY) {
let panSpeed = 2;
Expand Down

0 comments on commit 2f9d1c3

Please sign in to comment.