JavaScript MouseEvent buttons Property
You are Here:
JavaScript MouseEvent buttons Property
The event.buttons
property indicates which mouse button or buttons were pressed on the mouse to trigger the event.
Note: This property is read-only.
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<div onmousedown="myFunction(event)">
</div>
<h2>You Clicked : <span id="point"></span></h2>
<script>
function myFunction(event){
document.getElementById("point").innerHTML = event.buttons;
}
</script>
</body>
</html>
Syntax
event.buttons
Return Value
Value | Explanation |
---|---|
1 | When mouse left button is clicked. |
2 | When mouse right button is clicked. |
3 | When both left and right mouse button is clicked. |
4 | When middle mouse button is clicked. |
5 | When both left and middle mouse button is clicked. |
6 | When both right and middle mouse button is clicked. |
7 | When left, right and middle mouse button is clicked. |
8 | When fourth mouse button is clicked (typically the "Browser Back" button). |
16 | When fifth mouse button is clicked (typically the "Browser Forward" button). |
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.