Mega Code Archive

 
Categories / JavaScript Tutorial / Event
 

Event which

The which property refers to which key or mouse button was pressed or clicked. The value returned for mouse events is a numeric value 1, 2, or 3, representing the left, middle, and right mouse buttons, respectively. The value returned for keyboard events is a character representation for the key that was pressed. <html>     <head>     <title>Using the which property of the event object</title>     </head>     <body>     <form>     This example uses the which property of the event object to determine     which mouse button is pressed.     <br><br>     <input type="radio" onClick = 'alert("Mouse button Number " + event.which + "was pressed.")'>     </form>     </body>     </html>