fix: fix Alt key in keyboard shortcuts (#902)

fixes #896
This commit is contained in:
Nolan Lawson 2019-01-19 15:50:39 -08:00 committed by GitHub
parent 6b3d53a795
commit 031caec406
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -173,6 +173,7 @@ function unmapKeys (keyMap, keys, component) {
function acceptShortcutEvent (event) {
let { target } = event
return !(
event.altKey ||
event.metaKey ||
event.ctrlKey ||
(event.shiftKey && event.key !== '?') || // '?' is a special case - it is allowed

View file

@ -15,6 +15,7 @@ function KeyDownEvent (key) {
this.metaKey = false
this.ctrlKey = false
this.shiftKey = false
this.altKey = false
this.target = null
}
@ -222,4 +223,15 @@ describe('test-shortcuts.js', function () {
eventListener(new KeyDownEvent('a'))
assert.ok(globalA.pressed())
})
it('ignores alt key', function () {
let component = new Component()
addToShortcutScope('global', '1', component)
let event = new KeyDownEvent('1')
event.altKey = true
eventListener(event)
assert.ok(component.notPressed())
})
})