Javascript examples for DOM:Mouse Event
The buttons property indicates which mouse buttons were pressed.
This property is read-only.
A Number, representing one or more mouse buttons that were pressed.
For example, if the left button (1) and the right button (2) are pressed, the returned value is 1+2, which is 3).
Possible values:
The following code shows how to find out which mouse button(s) that was pressed:
<!DOCTYPE html> <html> <body> <div onmousedown="WhichButton(event)">Click this text</div> <h2>You pressed button: <span id="demo"></span></h2> <script> function WhichButton(event) {/*from w w w . j ava2 s .com*/ var x = event.buttons; document.getElementById("demo").innerHTML = x; } </script> </body> </html>