MouseEvent which Property

Example

Which mouse button was pressed when the mouse event was triggered:

button = event.which
Try it Yourself »

Description

Warning !

The which property is deprecated.

Use the button property instead.


Syntax

event.which

Technical Details

Return Value: A Number.
Which mouse button that was pressed:

0 : Left button
1 : Wheel or middle button (if present)
2 : Right button

For a left-hand configured mouse, the values are reversed.
DOM Version: DOM Level 2 Events

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.