From d2e211796b8369a0d37ea916aebd3ef64551a0aa Mon Sep 17 00:00:00 2001 From: Neil Jenkins Date: Mon, 4 Mar 2024 10:52:34 +1100 Subject: [PATCH] Fix undo shortcut sometimes not working Same deal - does the Shift modifier also modify the character? Just allow both. Fixes #457. --- source/keyboard/KeyHandlers.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/source/keyboard/KeyHandlers.ts b/source/keyboard/KeyHandlers.ts index 3411484..37bb51f 100644 --- a/source/keyboard/KeyHandlers.ts +++ b/source/keyboard/KeyHandlers.ts @@ -211,12 +211,15 @@ keyHandlers[ctrlKey + 'z'] = (self: Squire, event: KeyboardEvent): void => { event.preventDefault(); self.undo(); }; -keyHandlers[ctrlKey + 'y'] = keyHandlers[ctrlKey + 'Shift-z'] = ( - self: Squire, - event: KeyboardEvent, -): void => { - event.preventDefault(); - self.redo(); -}; +keyHandlers[ctrlKey + 'y'] = + // Depending on platform, the Shift may cause the key to come through as + // upper case, but sometimes not. Just add both as shortcuts — the browser + // will only ever fire one or the other. + keyHandlers[ctrlKey + 'Shift-z'] = + keyHandlers[ctrlKey + 'Shift-Z'] = + (self: Squire, event: KeyboardEvent): void => { + event.preventDefault(); + self.redo(); + }; export { _onKey, keyHandlers };