You can listen for the onkeypress
event. However, instead of just examining either the event.keyCode
(IE) or event.which
(Mozilla) property which gives you the key code, you need to translate the key code using String.fromCharCode()
.
A good demo is at Javascript Char Codes (Key Codes). View the source and look for the displayKeyCode(evt)
function.
Additional references: w3schools - onkeypress Event and w3schools - JavaScript fromCharCode() method.