Skip to content

Commit

Permalink
Fix modifiers triggering key down checks
Browse files Browse the repository at this point in the history
  • Loading branch information
pythongosssss committed Jan 13, 2024
1 parent 56d9496 commit df49a72
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions web/extensions/core/undoRedo.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const bindInput = (activeEl) => {
}
};

let keyIgnored = false;
window.addEventListener(
"keydown",
(e) => {
Expand All @@ -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;

Expand All @@ -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();
Expand Down

0 comments on commit df49a72

Please sign in to comment.