Event.isTrusted is a read-only boolean. It is true when the event was generated by the user agent (real user actions and some UA methods), and false when your script sent it with dispatchEvent(). (MDN: Baseline Widely available since September 2016; also in Web Workers.)
Read the notes below before you rely on this property. Prefer feature detection when support is limited.
Syntax
Use event.isTrusted. Start with this line.
JavaScript
event.isTrusted
Call
What it does
event.isTrusted
Primary signature.
Built into the browser. Read event.isTrusted on an Event instance — no import required.
Library declarations
JavaScript
event.isTrusted
Parameters
This member has no parameters beyond those shown in the signature.
Return Value
Return Value
Description
*
The current value of event.isTrusted.
JavaScript Examples
Example 1 — Real User Click (MDN Pattern)
A genuine click sets isTrusted to true.
JavaScript
button.addEventListener("click", (e) => {
if (e.isTrusted) {
console.log("The event is trusted");
} else {
console.log("The event is not trusted");
}
});
User clicks. The browser creates a normal click event.
Read the flag.e.isTrusted is true.
Branch. MDN’s simple if/else labels trusted vs not.
No assignment. You only read the boolean.
Example 2 — HTMLElement.click() Is Not Trusted
Calling button.click() from script sets isTrusted to false.
JavaScript
button.addEventListener("click", (event) => {
console.log(event.isTrusted); // false when fired via button.click()
});
button.click(); // scripted — not a real user gesture
Create an event.new MouseEvent("click", …) is script-made.
Dispatch it.dispatchEvent delivers it to listeners.
Flag is false. MDN: events from dispatchEvent() are not trusted.
Same for custom types.new Event("save") + dispatch is also untrusted.
Compatibility
Browser Support
Event.isTrusted is marked Baseline Widely available on MDN (since September 2016). It is also available in Web Workers.
✓ Baseline · Widely available
Event.isTrusted
Read-only boolean: true for user-agent–generated events, false for events dispatched via dispatchEvent().
UniversalWidely available
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
Event.isTrustedExcellent
Bottom line: Safe to use in modern browsers. Remember: element.click() and dispatchEvent() produce untrusted clicks.
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 such as HTMLElement.focus()), 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.