From 38447d337ec287e1fa5c938b9508dd4dae1071a4 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Sun, 12 Apr 2026 04:45:43 +0100 Subject: [PATCH] feat: implement keybinds to undo/redo the undo bind loads the last snapshot from undo-stack and applies state. the redo does exactly the same from the redo-stack. Signed-off-by: oppiliappan --- src/index.html | 6 +++++- src/js/input.js | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index 8cafec1..1405985 100644 --- a/src/index.html +++ b/src/index.html @@ -222,7 +222,9 @@ >remove selected Menu, Shift+F10, `context menuCtrl+Aselect allShift + ↑ / ↓extend selection - Escclear selection + Escclear selection Ctrl+Zundo last queue change Ctrl+Yredo queue change @@ -328,6 +330,8 @@ + + diff --git a/src/js/input.js b/src/js/input.js index d46899b..944c455 100644 --- a/src/js/input.js +++ b/src/js/input.js @@ -454,6 +454,26 @@ function setupKeyboardShortcuts() { } break; } + + case "KeyZ": { + // undo: Ctrl+Z + if (e.ctrlKey || e.metaKey) { + e.preventDefault(); + const snapshot = history.undo(snapshotQueue()); + restoreQueue(snapshot); + } + break; + } + + case "KeyY": { + // redo: Ctrl+Y + if (e.ctrlKey || e.metaKey) { + e.preventDefault(); + const snapshot = history.redo(snapshotQueue()); + restoreQueue(snapshot); + } + break; + } } }); } -- 2.51.2