What preferred way to reconcile keyCode/charCode across browsers?
Posted
by Drew Turner
on Stack Overflow
See other posts from Stack Overflow
or by Drew Turner
Published on 2010-05-26T22:09:06Z
Indexed on
2010/05/26
22:11 UTC
Read the original article
Hit count: 251
JavaScript
|keycode
Based on the properties of the keydown event I would like to ascertain what the current charCode are?
Example.
For the keydown event when the NumPad0, D0, and Colon key is pressed I would like to know what the associated charcode is. Currently I have a map that contains the charcode associated with that keyCode or use the current if charCode is not specified.
keyCode = {
Colon: 186,
D0: 48,
NumPad0: 96,
};
charCodes = {
186: 59,
96: 48,
};
shiftCharCodes = {
186: 58,
48: 41
};
Also in certain cases the keyCodes are different accross browsers?
Example.
The keydown event has different keyCode values across browsers. Colon Key (:/;) - keyCode is 59 on firefox - keyCode is 186 on IE/safari
For more information
© Stack Overflow or respective owner