References

Collection of references for web development.

HTML onkeydown event

Description

Execute JavaScript code when the user is pressing button.

Example

<div id="output">Type any key into the input field:</div>
<input type="text" onkeydown="document.getElementById('output').innerHTML = 'Character Code: ' + event.keyCode">

Example #2

<script>
function myFunction(event) {
	document.getElementById('output').innerHTML = 'Character Code: ' + event.keyCode; 
}
</script>
<div id="output">Type any key into the input field:</div>
<input type="text" onkeydown="myFunction(event)">