Get the key char from the key event in JavaScript
Description
The following code shows how to get the key char from the key event.
Example
<html>
<head>
<title>Key Events Example</title>
<script type="text/javascript">
function handleEvent(oEvent) {<!-- ww w.j a v a 2s.co m-->
var oTextbox = document.getElementById("txt1");
oTextbox.value += "\n charCode is " + oEvent.charCode;
}
</script>
</head>
<body>
<P>Type some characters into the first textbox.</p>
<P>
<textarea id="txtInput" rows="15" cols="50"
onkeypress="handleEvent(event)"></textarea>
</p>
<P>
<textarea id="txt1" rows="15" cols="50"></textarea>
</p>
</body>
</html>