diff --git a/src/routes/_utils/shortcuts.js b/src/routes/_utils/shortcuts.js index 2fe79fde..ed39ecc3 100644 --- a/src/routes/_utils/shortcuts.js +++ b/src/routes/_utils/shortcuts.js @@ -107,7 +107,7 @@ export function onKeyDownInShortcutScope (scopeKey, event) { } function handleEvent (scopeKey, keyMap, key, event) { - const value = keyMap[key] + const value = keyMap[key] || keyMap[key.toLowerCase()] // treat uppercase and lowercase the same (e.g. caps lock) if (!value) { return false } diff --git a/tests/unit/test-shortcuts.js b/tests/unit/test-shortcuts.js index 11ee3332..a71dd3f5 100644 --- a/tests/unit/test-shortcuts.js +++ b/tests/unit/test-shortcuts.js @@ -235,4 +235,16 @@ describe('test-shortcuts.js', function () { eventListener(event) assert.ok(component.notPressed()) }) + + it('works with caps lock on', function () { + const lmn = new Component() + + addToShortcutScope('global', 'z', lmn) + + assert.strictEqual(lmn.eventCount, 0) + eventListener(new KeyDownEvent('z')) + assert.strictEqual(lmn.eventCount, 1) + eventListener(new KeyDownEvent('Z')) + assert.strictEqual(lmn.eventCount, 2) + }) })