From 46bc36861ec16d98e011a470ad52555047616368 Mon Sep 17 00:00:00 2001 From: Neil Jenkins Date: Mon, 4 Mar 2024 10:52:07 +1100 Subject: [PATCH] Fix Shift-number shortcuts don't work on windows The perennial issue of should keyboard shortcuts be about the character or the key! --- source/keyboard/KeyHandlers.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/keyboard/KeyHandlers.ts b/source/keyboard/KeyHandlers.ts index e829e83..3411484 100644 --- a/source/keyboard/KeyHandlers.ts +++ b/source/keyboard/KeyHandlers.ts @@ -28,6 +28,12 @@ const _onKey = function (this: Squire, event: KeyboardEvent): void { // control key modifiers. let key = event.key; let modifiers = ''; + const code = event.code; + // If pressing a number key + Shift, make sure we handle it as the number + // key and not whatever different character the shift might turn it into. + if (/^Digit\d$/.test(code)) { + key = code.slice(-1); + } if (key !== 'Backspace' && key !== 'Delete') { if (event.altKey) { modifiers += 'Alt-';