JavaScript Event isTrusted Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

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
CallWhat it does
event.isTrustedPrimary 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 ValueDescription
*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");
  }
});
Try It Yourself

How It Works

  1. User clicks. The browser creates a normal click event.
  2. Read the flag. e.isTrusted is true.
  3. Branch. MDN’s simple if/else labels trusted vs not.
  4. 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
Try It Yourself

How It Works

  1. Register the listener. It will run for any click on the button.
  2. Call click(). This is a script API, not a mouse press.
  3. MDN rule. That click sets isTrusted to false.
  4. Use case. Skip analytics or “user confirmed” logic for scripted clicks.

Example 3 — dispatchEvent Is Not Trusted

Events you build and dispatch yourself are always untrusted.

JavaScript
button.addEventListener("click", (event) => {
  console.log(event.isTrusted); // false
});

button.dispatchEvent(
  new MouseEvent("click", { bubbles: true })
);
Try It Yourself

How It Works

  1. Create an event. new MouseEvent("click", …) is script-made.
  2. Dispatch it. dispatchEvent delivers it to listeners.
  3. Flag is false. MDN: events from dispatchEvent() are not trusted.
  4. Same for custom types. new Event("save") + dispatch is also untrusted.

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().

Universal Widely available
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
Event.isTrusted Excellent

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.

Next: originalTarget

See Firefox’s non-standard original target before retargeting.

originalTarget tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful