Onkeydown event In Java Script

This event occurs when user presses a key , at the time of pressing the key this event gets fired. When user presses a key from keyboard the key goes down and as soon as the key goes down this event gets fired and can be trapped by using onkeydown event. A programmer can get the key pressed by the user before flashing the character on the screen.


<title>events </title>


<body bgcolor=green text=yellow>

<h4 align =center> Type character in the textbox </h4>

<blockquote> You will notice that the dialogbox appears   before the character appears in the textbox </blockquote>

name : <input type=”text” name=”t1″ onkeydown=”ff()”>  


function ff()


alert(“you pressed “+ event.keyCode)





Scroll to Top