KeyEvent charCode Property - Get the Unicode value of the pressed keyboard key via charCode or keyCode property - Javascript DOM

Javascript examples for DOM:Key Event

Description

KeyEvent charCode Property - Get the Unicode value of the pressed keyboard key via charCode or keyCode property

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="text" size="40" onkeypress="myFunction(event)">

<p id="demo"></p>

<script>
function myFunction(event) {//from w  w w .  j  a v  a 2s . com
    var x = event.charCode || event.keyCode;
    document.getElementById("demo").innerHTML = "The Unicode value is: " + x;
}
</script>

</body>
</html>

Related Tutorials