Merge pull request #15267 from light-and-ray/prevent_alt_menu_on_firefox

prevent alt menu for firefox
This commit is contained in:
AUTOMATIC1111 2024-03-16 18:31:55 +03:00 committed by GitHub
commit 2f9d1c33e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;