The auxclick event fires when a non-primary pointer button (middle, right, or other) is pressed and released on the same element. Learn addEventListener vs onauxclick, event.button, how to cancel browser defaults, and how it differs from click—with five examples and try-it labs.
01
Kind
Instance event
02
Type
PointerEvent
03
When
Non-primary click
04
Handler
onauxclick
05
Order
After mouseup
06
Status
Baseline 2024
Fundamentals
Introduction
The familiar click event covers the primary button (usually left). For every other button—middle-click, right-click, and extra mouse buttons— browsers fire auxclick instead when press and release both happen on the same element.
MDN: auxclick fires aftermousedown and mouseup, in that order. That makes it the “click completed” signal for non-primary buttons.
💡
Beginner tip
You need a multi-button mouse (or equivalent) to try most demos. Touchscreens and trackpads may not produce a true middle-click. Prefer addEventListener("auxclick", ...) for production code.
Concept
Understanding auxclick
An instance event for non-primary pointer button clicks. It answers: “Did the user click this element with a button other than the primary one?”
Fires on non-primary button press + release on the same element.
Aftermousedown then mouseup.
PointerEvent today (inherits MouseEvent fields like button).
Baseline 2024 — newly available across latest browsers since Dec 2024.
Foundation
📝 Syntax
Use the event name with addEventListener, or set the handler property:
A PointerEvent (inherits from MouseEvent). Earlier specs used MouseEvent; check compatibility if you rely on Pointer-only fields.
Useful inherited properties
Property
Meaning
button
Which button changed: 1 middle, 2 right (typical)
buttons
Bitmask of buttons currently held
clientX / clientY
Pointer position in the viewport
pointerType
Device type when exposed as PointerEvent (mouse, etc.)
Important
⚠️ Preventing Default Actions
MDN highlights a few browser defaults that pair with non-primary clicks:
Middle-click open in new tab — usually cancelable with preventDefault() on auxclick.
Right-click context menu — prevent on contextmenu, not only on auxclick (OS timing differs).
Middle-button down actions (autoscroll on Windows, paste on some macOS/Linux setups) — prevent on mousedown / pointerdown.
Compare
⚖️ auxclick vs click vs contextmenu
Event
Typical trigger
Use for
click
Primary (left) button
Main UI actions
auxclick
Non-primary buttons
Middle/right/extra button actions
contextmenu
Right-click / keyboard menu key
Custom menus; cancel system menu
Caveat
🌐 Baseline 2024 (Newly Available)
MDN marks auxclick as Baseline 2024: newly available across the latest devices and browser versions since December 2024. It is not Deprecated, Experimental, or Non-standard—but older browsers may lack support, so feature-detect or provide a fallback if you support legacy clients.
Cheat Sheet
⚡ Quick Reference
Goal
Code / note
Listen
el.addEventListener("auxclick", fn)
Handler property
el.onauxclick = fn
Which button?
event.button (1 middle, 2 right)
Block new tab
event.preventDefault() in auxclick
Block context menu
preventDefault() on contextmenu
Event order
mousedown → mouseup → auxclick
MDN status
Baseline 2024 (newly available)
Snapshot
🔍 At a Glance
Four facts to remember about auxclick.
Event type
PointerEvent
via MouseEvent
Means
non-primary
Not left-click
After
mouseup
Then auxclick
Baseline
2024
Newly available
Hands-On
Examples Gallery
Examples follow MDN Element: auxclick event. Try It Yourself labs work best with a multi-button mouse—middle-click or right-click the targets.
📚 Getting Started
Register handlers the MDN ways.
Example 1 — addEventListener("auxclick")
Listen for any non-primary button click on an element.
JavaScript
const box = document.getElementById("box");
box.addEventListener("auxclick", () => {
console.log("auxclick fired");
});
// Middle-click or right-click the box (not left-click).
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 lack it—test if you support legacy clients.
✓ Baseline 2024 · Newly available
Element auxclick
Works across the latest major browsers for non-primary pointer button clicks.
2024Baseline year
Google ChromeSupported · Modern versions
Full support
Mozilla FirefoxSupported · Modern versions
Full support
Apple SafariSupported in Baseline 2024 set
Full support
Microsoft EdgeSupported · Chromium
Full support
OperaSupported · Modern versions
Full support
Internet ExplorerNo auxclick support
Unavailable
auxclickBaseline 2024
Bottom line: Use for middle/right/extra button clicks. Pair with contextmenu and mousedown preventDefault when canceling browser defaults.
Wrap Up
Conclusion
auxclick is the non-primary-button counterpart to click. Listen with addEventListener, inspect event.button, and use the right companion events (contextmenu, mousedown) when you need to cancel browser defaults.
Prevent contextmenu when building custom right-click UI
Test with a real multi-button mouse
Keep primary actions on click for accessibility
❌ Don’t
Expect auxclick from left-click
Assume every device has a middle button
Rely only on auxclick to hide the context menu
Ignore Baseline 2024 if you still support very old browsers
Overwrite onauxclick if you need multiple listeners
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about auxclick
Non-primary button click completed—handle middle, right, and extras.
5
Core concepts
🖱️01
Non-primary
not left-click
Event
📍02
PointerEvent
+ MouseEvent
API
🔢03
event.button
1 / 2 / …
Detail
🚫04
Defaults
aux + contextmenu
Cancel
🎯05
Baseline 2024
newly available
Compat
❓ 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. 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 inherited 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.
Yes in most browsers that map middle-click to open-in-new-tab: call event.preventDefault() inside the auxclick handler. 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.
Did you know?
On many gaming mice, “special” side buttons also count as non-primary and can fire auxclick. Always inspect event.button instead of assuming only middle and right exist.