In theory, according to DOM3 Events , you should use the property keyof the event object. In practice, this does not work, with the exception of fairly new versions of IE.
A practical approach is to use a property whichor property charCode, although the DOM3 Events project frowns at them:
, keyCode, charCode which.
, : keyCode - . charCode - ASCII . which - , , . , , , .
charCode Unicode ( ).
( ):
<style>
#o { border: solid black 1px; }
</style>
<input id=i>
<div id=o></div>
<script>
document.getElementById('i').onkeypress = function (e) {
var ev = e || window.event;
document.getElementById('o').innerHTML +=
ev.charCode + ' ';
}
</script>
, , , IE 9 . - keyCode .