The click event is the everyday “user activated this control” signal. Learn addEventListener vs onclick, mouse / touch / keyboard activation, event.detail click counts, order vs mousedown / mouseup, and five try-it labs.
01
Kind
Instance event
02
Type
PointerEvent
03
After
mousedown + mouseup
04
Handler
onclick
05
Useful field
event.detail
06
Status
Baseline widely available
Fundamentals
Introduction
Almost every interactive page starts with a click handler. The browser fires click for the primary pointing-device button (press and release inside the element), for many touch activations, and for keyboard equivalents such as Space or Enter on buttons and links.
It is a device-independent activation event: mouse, touch, keyboard, and assistive technology can all produce it. Prefer click for primary actions so keyboard users are included—not only mousedown.
💡
Beginner tip
Use addEventListener("click", ...) for primary UI actions. Use auxclick when you need non-primary mouse buttons (middle / right).
Concept
Understanding click
An instance event that answers: “Was this element activated in a click-like way?”
Fires on primary button press+release, many touches, and default keyboard activation.
Order — after mousedown then mouseup.
PointerEvent (inherits MouseEvent) in modern specs.
detail — consecutive click count (2 = double-click streak, and so on).
Baseline Widely available on MDN (since July 2015).
Foundation
📝 Syntax
Use the event name with addEventListener, or set the handler property:
Keyboard or some touch paths may not produce the same mouse pair, but a classic mouse click follows this sequence.
Example 5 — Keyboard Activation on a Button
Focus the button and press Enter or Space—click still fires.
JavaScript
const button = document.getElementById("go");
const out = document.getElementById("out");
button.addEventListener("click", () => {
out.textContent = "Activated (mouse, touch, or keyboard)";
});
// Tab to the button, then press Enter or Space.
click is marked Baseline Widely available on MDN (since July 2015). Logos use the shared browser-image-sprite.png sprite from this project. PointerEvent typing and some pointer-only fields can still differ by engine.
✓ Baseline · Widely available
Element click
Works across modern desktop and mobile browsers for primary activation via mouse, touch, and keyboard.
100%Widely available
Google ChromeSupported · Desktop & Android
Full support
Mozilla FirefoxSupported · Desktop & Android
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
OperaSupported · Modern versions
Full support
Internet ExplorerSupported (legacy MouseEvent era)
Supported
clickBaseline
Bottom line: Use click for primary actions so keyboard and pointer users share the same handler path.
Wrap Up
Conclusion
click is the standard primary-activation event for elements. Listen with addEventListener, use detail when streak counts matter, and keep primary actions on click so keyboard users are included.
Prefer addEventListener("click", ...) for primary actions
Use semantic <button> / links for keyboard click support
Read event.detail when multi-click streaks matter
Delegate from parents for lists and toolbars
Test with Tab + Enter / Space, not only the mouse
❌ Don’t
Rely only on mousedown for primary actions
Assume Space/Enter click every tabindex element
Use click for middle/right buttons—prefer auxclick
Forget that press-and-drag-out changes the event target
Overwrite onclick if you need multiple listeners
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about click
Primary activation for mouse, touch, and keyboard—one handler path.
5
Core concepts
🖱️01
Primary activate
press + release
Event
📄02
PointerEvent
modern type
API
🔢03
detail
click streak
Field
⏱️04
After up/down
mouse order
Sequence
🎯05
Baseline
widely available
Compat
❓ Frequently Asked Questions
An element receives click when a pointing-device primary button is pressed and released inside it, when a touch gesture activates it, or when an equivalent action occurs (such as Space or Enter on elements that have a default key handler).
No. MDN marks Element click as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard. Some parts of the feature may have varying support levels.
A PointerEvent (inherits from MouseEvent). Older specifications used MouseEvent; check compatibility if you rely on PointerEvent-only fields.
click fires after both mousedown and mouseup have fired, in that order.
For click, detail is the number of consecutive clicks on the target (2 for double-click, 3 for triple-click, and so on). The counter resets after a short idle interval that can vary by browser and user settings.
Space and Enter click activation applies to elements with a default key event handler (for example buttons and links). Merely adding tabindex does not automatically give every element that keyboard click behavior.
Did you know?
If you press the mouse button on one element and release on another, the browser fires click on the most specific ancestor that contained both elements—not necessarily the element where you started the press.