Key events
Tested with Opera 9, FireFox 1.5 and IE 6
IE's keyCode property by event type
| Type of key / event | keydown | keypress | keyup |
| Alphanumeric | keyboard reference | character reference | keyboard reference |
| Punctuation | keyboard reference | character reference | keyboard reference |
| Function keys | keyboard reference | N/A - event does not fire | keyboard reference |
Opera - as IE except..
| Type of key / event | keydown | keypress | keyup |
| Punctuation | character reference | | character reference |
| Function keys | | keyboard reference (or 0) | |
Mozilla keyCode - as IE except..
| Type of key / event | keydown | keypress | keyup |
| Alphanumeric | | 0 | |
| Punctuation | | 0 | |
| Function keys | | keyboard reference | |
Mozilla's charCode property
| Type of key / event | keydown | keypress | keyup |
| Alphanumeric | 0 | character reference | 0 |
| Punctuation | 0 | character reference | 0 |
| Function keys | 0 | 0 | 0 |
Summary
- Opera treats punctuation keys differently, event.keyCode is ASCII value for down/up
- IE does not fire keypress for function keys. Opera and FireFox do.
- Mozilla wants you to use the property name charCode if the event is keypress and the key is not a function key, keyCode otherwise