Closed Bug 2002824 Opened 11 months ago Closed 11 months ago

MouseEvent.button() fails to detect buttons 4, 5 or above

Categories

(Firefox :: Untriaged, defect)

Firefox 145
defect

Tracking

()

RESOLVED DUPLICATE of bug 1841756

People

(Reporter: connorks848411, Unassigned)

Details

Attachments

(1 file)

Steps to reproduce:

It is possible to detect and distinguish what button on a pointing device is pressed using MouseEvent. On Firefox, the left (0), right (2) and middle (1) buttons are detected as one would expect, however the fourth/back (3) and fifth/forward (4) buttons are not, nor are any buttons beyond the fifth (5, 6, 7, ...). This is inconsistent with other browser engines such as Chromium and Ladybird, which can at least detect the first five buttons, and the w3c specification says that even values above this may be permitted.

I have a simple test case set up here: https://muzikbike.github.io/tests/mouse-button-recognition/index.html

Perhaps amusingly, this Mozilla Developer page explicitly mentions values for the fourth and fifth buttons, despite Firefox not producing these values: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button

Nightly 147.0a1 (2025-11-27) (64-bit) still appears to be subject to this issue.

  • Own a mouse with at least four buttons (the more, the better), or have a program that can input such button press events
  • Navigate to a page that can detect specific mouse button presses, such as those linked above (it may be best to "open in new tab" so that the tab has no history)
  • Place the cursor on top of the button element
  • Push each of the buttons on your mouse while your cursor is in position
  • Note the outputs for each mouse button press

Actual results:

The left button produces a value of 0, the right button produces a value of 2, and the middle button produces a value of 1. This is as expected.

The fourth and fifth mouse buttons do nothing at all (no output is provided). Indeed, if the tab has browsing history in either direction, these buttons will navigate back and forward, which violates the preventDefault() specified in the script.

The sixth, seventh, eighth, ... mouse buttons also do nothing at all.

Expected results:

The fourth and fifth mouse buttons would give values 3 and 4 respectively. Buttons 6, 7, 8 and above would also preferably give outputs 5, 6, 7, and so on.

Status: UNCONFIRMED → RESOLVED
Closed: 11 months ago
Duplicate of bug: 1841756
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: