fix: hotkeys work with caps lock on (#1531)

fixes #1530
This commit is contained in:
Nolan Lawson 2019-09-24 18:46:53 -07:00 committed by GitHub
parent 3a2fe740c1
commit 65524105f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -107,7 +107,7 @@ export function onKeyDownInShortcutScope (scopeKey, event) {
} }
function handleEvent (scopeKey, keyMap, key, 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) { if (!value) {
return false return false
} }

View file

@ -235,4 +235,16 @@ describe('test-shortcuts.js', function () {
eventListener(event) eventListener(event)
assert.ok(component.notPressed()) 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)
})
}) })