In JavaScript, the auxclick event fires when a non-primary pointing-device button (any mouse button other than the primary/left button) is pressed and released on the same element (MDN). It fires after mousedown and mouseup, in that order.
Register a listener with addEventListener. Check readiness and browser support before you rely on this event.
Syntax
Listen for auxclick. Start with this line.
JavaScript
el.addEventListener("auxclick", fn)
Call
What it does
el.addEventListener("auxclick", fn)
Primary signature.
Built into the browser. Listen with el.addEventListener("auxclick", …) — no import required.
Library declarations
JavaScript
el.addEventListener("auxclick", fn)
Parameters
Parameter
Description
Non-primary button
Required. Press + release on the same element
preventDefault()
Optional. Cancel some browser defaults
Return Value
Return Value
Description
*
Fires as an Element event (listener receives the Event object).
auxclick handled
/* context menu suppressed via contextmenu */
How It Works
Handle auxclick.preventDefault() can stop middle-click new tab (MDN).
Handle contextmenu separately. Menu timing differs by OS (MDN).
Do not rely on auxclick alone to hide the context menu.
For autoscroll/paste, also consider mousedown / pointerdown defaults (MDN).
Compatibility
Browser Support
Element.auxclick is marked Baseline 2024 on MDN (Newly available since December 2024). Logos use the shared browser-image-sprite.png sprite from this project. Older browsers may still lack full support.
✓ Baseline 2024 · Newly available
Element auxclick
Fires for non-primary pointer button clicks — after mousedown and mouseup.
2024Baseline
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported in modern versions
Full support
Microsoft EdgeSupported · Chromium
Full support
OperaSupported · Modern versions
Full support
Internet ExplorerNot supported
Not supported
auxclickBaseline 2024
Bottom line: Use for middle/right-click UX in modern browsers. Prefer feature checks in older environments. See the MDN Element auxclick reference.
Frequently Asked Questions
It fires when a non-primary pointing device button (any mouse button other than the primary/left button) is pressed and released on the same element (MDN). Typical cases are middle-click and right-click.
No. MDN marks Element auxclick as Baseline 2024 (Newly available since December 2024). It is not Deprecated, Experimental, or Non-standard.
A PointerEvent (inherits from MouseEvent). Older browsers may expose it as a MouseEvent. Useful fields include button, buttons, clientX/clientY, and modifier keys.
After both mousedown and mouseup have fired, in that order, for the non-primary button press/release on the same element (MDN).
Yes in most browsers that map middle-click to open-in-new-tab: call event.preventDefault() inside the auxclick handler (MDN). To block the right-click context menu, preventDefault on the contextmenu event instead.
click is for the primary button. auxclick is for non-primary buttons. Use click for left-click UI and auxclick for middle/right (and other) buttons.