Fix modifiers triggering key down checks

This commit is contained in:
pythongosssss 2024-01-13 17:00:30 +00:00
parent 56d9496b18
commit df49a727ff
1 changed files with 11 additions and 0 deletions

View File

@ -106,6 +106,7 @@ const bindInput = (activeEl) => {
}
};
let keyIgnored = false;
window.addEventListener(
"keydown",
(e) => {
@ -116,6 +117,9 @@ window.addEventListener(
return;
}
keyIgnored = e.key === "Control" || e.key === "Shift" || e.key === "Alt" || e.key === "Meta";
if (keyIgnored) return;
// Check if this is a ctrl+z ctrl+y
if (await undoRedo(e)) return;
@ -127,6 +131,13 @@ window.addEventListener(
true
);
window.addEventListener("keyup", (e) => {
if (keyIgnored) {
keyIgnored = false;
checkState();
}
});
// Handle clicking DOM elements (e.g. widgets)
window.addEventListener("mouseup", () => {
checkState();