mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-03-03 20:44:54 +08:00
check e.key in up event
This commit is contained in:
parent
9142ce8188
commit
eb2ea8df1d
@ -841,24 +841,24 @@ onUiLoaded(async() => {
|
|||||||
|
|
||||||
|
|
||||||
// Prevent firefox to open toolbar on pressing alt
|
// Prevent firefox to open toolbar on pressing alt
|
||||||
let isAltPressed = false;
|
let wasAltPressed = false;
|
||||||
|
|
||||||
function handleAltKeyDown(e) {
|
function handleAltKeyDown(e) {
|
||||||
if (!activeElement) return;
|
if (!activeElement) return;
|
||||||
if (hotkeysConfig.canvas_hotkey_zoom !== "Alt") return;
|
if (hotkeysConfig.canvas_hotkey_zoom !== "Alt") return;
|
||||||
if (e.code === "AltLeft" || e.code === "AltRight") {
|
if (e.code === "AltLeft" || e.code === "AltRight") {
|
||||||
isAltPressed = true;
|
wasAltPressed = true;
|
||||||
} else {
|
} else {
|
||||||
isAltPressed = false;
|
wasAltPressed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAltKeyUp(e) {
|
function handleAltKeyUp(e) {
|
||||||
if (hotkeysConfig.canvas_hotkey_zoom !== "Alt") return;
|
if (hotkeysConfig.canvas_hotkey_zoom !== "Alt") return;
|
||||||
if (isAltPressed) {
|
if (wasAltPressed || (activeElement && e.key === "Alt")) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
isAltPressed = false;
|
wasAltPressed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("keydown", handleAltKeyDown);
|
document.addEventListener("keydown", handleAltKeyDown);
|
||||||
|
Loading…
Reference in New Issue
Block a user