javascript event keyCode
keyCode | Firefox/Netscape/NN 6 IE 4 Chrome/Safari/DOM n/a |
|
Read/Write |
Slightly different characteristics for IE and Netscape 6, but the two browser classes treat the keyCode property the same way for onkeydown and onkeyup events. For these events, the keyCode property returns the code associated with the keyboard key, irrespective of the character that might be generated by that key. On a typical Latin character set keyboard, the A key generates the code 65. Modifier keys generate their own events and codes as they are pressed and released. |
|
For the onkeypress event, only IE returns a significant value, corresponding to the Unicode value of the actual character displayed in a text box by typing the character (e.g., 65 for "A" and 97 for "a"). The equivalent property in Netscape 6 for the onkeypress event is charCode. |
|
Example | |
if (evt.keyCode == 65) { ... } |
|
Value | |
Integer. |
|
Default | |
None. |
Powered by Linode.