|
|
Finding Event Key Codes using javascript - Javascript
|
Views : 468
|
|
Tagged in : Javascript
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
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 |
|
|
|