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

ValueExplanation
1When mouse left button is clicked.
2When mouse right button is clicked.
3When both left and right mouse button is clicked.
4When middle mouse button is clicked.
5When both left and middle mouse button is clicked.
6When both right and middle mouse button is clicked.
7When left, right and middle mouse button is clicked.
8When fourth mouse button is clicked (typically the "Browser Back" button).
16When 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.

Share this Page

Meet the Author