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:
Kevin Sawicki
2013-07-02 13:13:45 -07:00
parent 64e2fee975
commit c7f6e87132

View File

@@ -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'