Reputation: 21449
Why are some keycodes converted to other characters?
I think 219 should be the [ character.
onKeyPress I get 91
onKeyDown I get 219
firefox, test page: http://www.asquare.net/javascript/tests/KeyCode.html
Update: the confusion was generated by the keycode of onKeyPress and onKeyDown event. onKeyPress the character code is returned ( 91 ) and onKeyDown the key code is returned ( 219 ).
This table shows both ascii code and key code ( by browser ). http://unixpapa.com/js/key.html
Upvotes: 2
Views: 679
Reputation: 50712
It converts to Unicode, here is Here is table of conversion, use 91 instead
Upvotes: 1
Reputation: 16754
W3Schools says:
Definition and Usage
The fromCharCode() method converts Unicode values into characters.
Note: This is a static method of the String object, and the syntax is always String.fromCharCode().
Instead of 219
must be 91
for [
character
219
means for keyCode not charCode
Upvotes: 0
Reputation: 2468
That's for Unicode. It's taking the Unicode values and converting it to Unicode characters.
Upvotes: 2