fix(keyHelper): handle control key & format in uppercase

This commit is contained in:
EnixCoda 2018-06-10 02:11:49 +08:00
parent 16de00272c
commit 3525de1dd4
2 changed files with 8 additions and 6 deletions

View file

@ -33,6 +33,7 @@ function friendlyFormatShortcut(shortcut) {
.replace(/ctrl/, '⌃')
.replace(/shift/, '⇧')
.replace(/alt/, '⌥')
.toUpperCase()
} else {
return shortcut
}

View file

@ -3,7 +3,7 @@ const keyCodeArray = [
...'`[]\\;\',./'.split(''),
'alt',
'shift',
'control',
'ctrl',
'meta',
]
const validKeyCodes = new Set(keyCodeArray)
@ -33,11 +33,12 @@ function parse(keysString) {
}
function parseKeyCode(code) {
let c = code.toLowerCase()
c = c.replace(/(left|right)$/, '')
c = c.replace(/^digit/, '')
c = c.replace(/^key/, '')
return c
return code
.toLowerCase()
.replace(/(left|right)$/, '')
.replace(/^control$/, 'ctrl')
.replace(/^digit/, '')
.replace(/^key/, '')
}
function parseEvent(e) {