mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Only use event.which when key identifier is non-ASCII
Previously event.which was used when it was less than the key identifier which broke fn-delete since that generates a valid key identifier but a lower event.which value that does not translate to 'delete' using the char code converter. Close #611
This commit is contained in:
@@ -150,7 +150,7 @@ class Keymap
|
||||
if event.originalEvent.keyIdentifier.indexOf('U+') == 0
|
||||
hexCharCode = event.originalEvent.keyIdentifier[2..]
|
||||
charCode = parseInt(hexCharCode, 16)
|
||||
charCode = Math.min(event.which, charCode) if event.which?
|
||||
charCode = event.which if !@isAscii(charCode) and @isAscii(event.which)
|
||||
key = @keyFromCharCode(charCode)
|
||||
else
|
||||
key = event.originalEvent.keyIdentifier.toLowerCase()
|
||||
@@ -171,6 +171,9 @@ class Keymap
|
||||
|
||||
[modifiers..., key].join('-')
|
||||
|
||||
isAscii: (charCode) ->
|
||||
0 <= charCode <= 127
|
||||
|
||||
keyFromCharCode: (charCode) ->
|
||||
switch charCode
|
||||
when 8 then 'backspace'
|
||||
|
||||
Reference in New Issue
Block a user