Finding Event Key Codes using javascript - Javascript Views : 468
Tagged in : Javascript
0 0
Send mail
Finding Event Key Codes using javascript

Use the below code to get keyboard key event number when the specific key is pressed using javascript:

document.onkeydown = trigger;
function trigger(e)
{
if (!e) var e = window.event;
if (e.keyCode) x = e.keyCode;
else if (e.which) x = e.which; // Here x is the key code

alert ("You have pressed the key event "+x+" in keyboard");
}


Result :

If you press space bar the result will be



By Sanju, On - 2010-02-01



    Login to add Comments .