Return the type of event that was triggered:
var x = event.type;
Press any key or click the mouse in this document to get what type of event that was triggered.
<!DOCTYPE html> <html> <body onmousedown="myFunction(event)" onmouseup="myFunction(event)" onkeydown="myFunction(event)" onkeyup="myFunction(event)"> <p>Event: <span id="demo"></span></p> <script> function myFunction(event) {//from w w w . j av a2 s . c om var x = event.type; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The type event property returns the type of the triggered event.