The isTrusted property is a read-only boolean on every Event: true when the user agent generated the event, and false when your script sent it with dispatchEvent(). Learn the HTMLElement.click() exception, MDN’s simple check, and practical patterns—with five examples and try-it labs.
01
Kind
Instance property
02
Type
boolean (read-only)
03
true
UA-generated
04
false
dispatchEvent / .click()
05
Forge?
Cannot set it
06
Status
Baseline widely
Fundamentals
Introduction
Your click handler cannot tell “who” clicked just by looking at event.type. Real mouse/keyboard input and events you create in JavaScript can look the same—unless you read event.isTrusted.
When the browser (user agent) creates the event for a real interaction—or for some of its own programmatic methods such as HTMLElement.focus()—MDN documents isTrusted as true. When you call target.dispatchEvent(new Event(…)), it is false. Calling element.click() also produces a click with isTrusted === false.
💡
Beginner tip
You cannot assign event.isTrusted = true. The browser owns this flag. Scripts cannot fake a trusted event that way.
Concept
Understanding Event.isTrusted
An instance property that answers: “Did the user agent generate this event, or did script dispatch it?”
true — generated by the user agent (user actions and some UA methods such as focus()).
false — dispatched via EventTarget.dispatchEvent(), or a click from HTMLElement.click().
Read-only — cannot be forged by assignment.
Baseline Widely available on MDN (since September 2016); also in Web Workers.
Foundation
📝 Syntax
JavaScript
event.isTrusted
Value
A boolean value.
MDN check
JavaScript
if (e.isTrusted) {
/* The event is trusted */
} else {
/* The event is not trusted */
}
button.addEventListener("click", (e) => {
if (e.isTrusted) {
out.textContent = "The event is trusted";
} else {
out.textContent = "The event is not trusted";
}
});
Event.isTrusted is marked Baseline Widely available on MDN (since September 2016). Logos use the shared browser-image-sprite.png sprite from this project. It is also available in Web Workers.
✓ Baseline · Widely available
Event.isTrusted
Read-only boolean: true for user-agent-generated events, false for dispatchEvent() and HTMLElement.click().
UniversalWidely available
Google ChromeFull support · Desktop & Mobile
Full support
Mozilla FirefoxFull support · Desktop & Mobile
Full support
Apple SafariFull support · macOS & iOS
Full support
Microsoft EdgeFull support · Chromium
Full support
OperaFull support · Modern versions
Full support
Internet ExplorerSupported in modern IE versions (legacy)
Full support
Event.isTrustedExcellent
Bottom line: Use isTrusted to tell real UA events from scripted ones—never try to assign the flag yourself.
Wrap Up
Conclusion
Event.isTrusted tells you whether the user agent generated the event or your script dispatched it. Remember that element.click() is untrusted, and that you cannot forge the flag yourself.
Assume every browser method produces untrusted events
Confuse isTrusted with defaultPrevented
Treat it as the only security control for critical actions
Forget that automated .click() is untrusted
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about isTrusted
The UA vs script flag on every Event.
5
Core concepts
🔒01
Boolean
read-only
API
✅02
true
UA-generated
Trusted
🚫03
false
dispatch / .click()
Script
🛡️04
Cannot forge
no assignment
Rule
🎯05
Baseline
since Sep 2016
Status
❓ Frequently Asked Questions
It is a read-only boolean on an Event. It is true when the event was generated by the user agent (including many user actions and some programmatic UA methods), and false when the event was dispatched via EventTarget.dispatchEvent().
No. MDN marks Event.isTrusted as Baseline Widely available (since September 2016). It is not Deprecated, Experimental, or Non-standard. It is also available in Web Workers.
No. MDN states that the click event fired through HTMLElement.click() sets isTrusted to false.
MDN notes that events generated by the user agent—including via programmatic methods such as HTMLElement.focus()—can be trusted (isTrusted true), unlike events you create and send with dispatchEvent().
No. It is read-only. Scripts cannot forge a trusted event by assigning event.isTrusted = true.
When you want to treat real user (or UA) interactions differently from synthetic events you dispatched—for example logging, analytics, or avoiding accidental double-handling of scripted clicks.
Did you know?
isTrusted is about who created the event, not about whether the default action was blocked. An untrusted event can still bubble, and a trusted event can still have defaultPrevented === true.