From 112519f6b0a29e940c50d0b17ddfbf61d29f64d7 Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Fri, 18 Feb 2022 11:18:20 +0100 Subject: [PATCH] fix: reset keys on window blur --- packages/histoire/src/client/app/util/keyboard.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/histoire/src/client/app/util/keyboard.ts b/packages/histoire/src/client/app/util/keyboard.ts index ea2676ba..5cee298a 100644 --- a/packages/histoire/src/client/app/util/keyboard.ts +++ b/packages/histoire/src/client/app/util/keyboard.ts @@ -51,6 +51,14 @@ window.addEventListener('keyup', event => { }) }) +window.addEventListener('blur', () => { + pressedKeys.clear() + for (const i in modifiers) { + const mod = modifiers[i] + mod.pressed = false + } +}) + function isMatchingShortcut (shortcut: KeyboardShortcut): boolean { for (const combination of shortcut) { if (isMatchingCombination(combination.toLowerCase())) {