skip to content

behavior and biometrics · lesson 1 of 7 · sources checked 2026-11-20

input events and event trust

This lesson shows what the trust flag of an input event proves and does not prove, and which fields a detector reads with it.

status of this lesson: from a public source

purpose

A site that reads input must first know which events came from the browser and which came from a page script. The behavior layer starts with this one cheap check. If you read the check as proof of a person, your detector accepts automation that it can catch with the next fields.

objectives

  1. Explain what the trust flag of an event proves and what it does not prove.
  2. Name the event fields that a detector reads together with the trust flag.
  3. Separate three input paths into a page by the checks that each path passes.
  4. Record pointer and key events on your own lab page, with key timing only.

new terms

behavior layer
The detection layer that examines how a visitor moves, types, touches, and waits.
trusted event
An input event that the browser marks with `isTrusted: true` because it came from the user agent, not from a page script.
signal
One observed value that a detector uses as evidence.
driver
Software that controls an unmodified browser through a protocol.
CDP
Chrome DevTools Protocol, a JSON message protocol that controls and examines a Chromium browser.
coalesced events
The pointer samples that the browser groups into one event between two frames.
benchmark platform
My test system. It runs browsers and tools against test pages and records the result.
personal data
Information about an identified or identifiable person, also when it is public.
probe
One check that reads one signal and gives a value, for example a page check or a check of the benchmark platform for each attempt.

how it works

Each input event in the browser carries a flag isTrusted. An event with isTrusted: true is a trusted event.

what the flag says

MDN states that isTrusted is true when the user agent generates the event. This includes user actions and methods such as HTMLElement.focus(). It is false when a script sends the event with dispatchEvent() MDN, source 1.

For example, a click that a script starts with HTMLElement.click() has isTrusted: false. A page script reads the flag with no permission and no cost. Thus a false flag is a strong signal at once.

what the flag does not say

A true flag shows that the browser made the event. It does not show who moved the device. Thus isTrusted is a first filter, not proof of a person. Three input paths reach a page:

  1. A page script calls dispatchEvent(). The event has isTrusted: false.
  2. A driver sends an input command through CDP. The Input domain of CDP has commands that send mouse, key, and touch events into the page Google (ChromeDevTools), source 2.
  3. The operating system (OS) sends input from a device, or from software that acts as a device.

For example, path 3 gives isTrusted: true also when software, not a hand, makes the device input.

A lab result of this course: the trust flag can be true for protocol input. Thus the flag does not separate protocol input from the input of a person. A detector must not depend on the flag for this path.

OS input passes the trust check. But the path of the pointer and the time between events stay visible to the page.

the fields to read with the flag

A detector reads the flag together with more fields of the same event:

  • pointerType: the Pointer Events specification gives mouse, pen, and touch. If the user agent cannot detect the device type, the value is an empty string W3C, source 3.
  • pressure: MDN gives a normalized value from 0 to 1, for the minimum and the maximum pressure that the hardware can detect MDN, source 4.
  • getCoalescedEvents(): the same specification lets a user agent delay a pointermove event, and this method returns the list of coalesced events.
  • navigator.userActivation: MDN states that isActive shows a current interaction (transient activation), and hasBeenActive shows any interaction on the page (sticky activation) MDN, source 5.

In my model, each field is a check of agreement with the others. For example, a pointermove with pointerType: "mouse" and no coalesced samples, after a long move, is a field signal. A click with no sticky activation before it is a second one.

the rest of the behavior layer

The trust check and the fields are the cheap part. The path of the pointer and the time between actions carry more information, and later lessons of the module read them. For example, the time from a key press to its release is one of these values. More detail on the path is in Mouse paths and kinematics (not yet published).

what the benchmark platform records

status of this section: documented in my test system

The benchmark platform, my test system, keeps a list of the browser fields that detection scripts read. It makes the list from the code of these scripts, and does not run them. The event fields and the trust signals of this list are on the reference page of isTrusted.

For example, the list shows if a detection script reads isTrusted, and you can compare it with the fields that your own sensor script reads.

the two sides

automation sidedetection side
An event from dispatchEvent() fails the trust check at once. OS input passes it, but the pointer path and the time between events stay visible. For protocol input, a detector must not depend on the trust flag.isTrusted is a cheap first filter. It does not prove a person. Read the pointer type, the pressure, the coalesced samples, and the activation state with it.

design decisions

optiongaincostwhen it is correct
Refuse each event with isTrusted: falseA script-made event never counts as input.An event of your own page code or of a test tool on your page also fails.On a form or a control where only a person acts
Use isTrusted as one feature of a scoreThe flag adds a cheap signal and does not decide alone.The score must have more fields and a baseline.On each page that has a behavior score
Read the pointer and activation fields with the flagA trusted event with fields that do not agree gives a signal.A browser can give a default value for a field.When the trust flag alone accepts too much
Record key timing only, with no key valueThe record holds less personal data.A study of what the user typed is not possible.On each capture of key events

diagram

three input paths into a page and the checks that each path passes or fails

A true trust flag ends only the first check. The fields, the path, and the time still decide the score.source: My model of the input paths into a page and their checks

a sensor script on your own lab page: listeners, event fields, timing reads, and the post to a collector

The sensor script posts only time, position, and trust. It never posts a key value.source: My model of a sensor script on a lab page

code example

The example is a recorder for your own lab page. On the page, you add it as a listener for pointer and key events. Here it reads a synthetic list of seven events that I made by hand. No row comes from a person.

m16-x01-event-recorder.tstypescript

Record pointer and key events of your own lab page: time, position, isTrusted, pointerType, and the coalesced count. For keys, record the time only, never the key value.

// Event recorder for your own lab page. It keeps time, position, trust,
// pointer type, and the coalesced count. For keys, it keeps time only.
type PointerLike = {
  type: string; timeStamp: number; isTrusted: boolean;
  pointerType: string; clientX: number; clientY: number;
  getCoalescedEvents?: () => unknown[];
};
type KeyLike = { type: string; timeStamp: number; isTrusted: boolean };
type Row = { t: number; kind: string; trusted: boolean; x?: number;
  y?: number; pointer?: string; coalesced?: number };

const rows: Row[] = [];

function onPointer(e: PointerLike): void {
  const coalesced = e.getCoalescedEvents ? e.getCoalescedEvents().length : 0;
  rows.push({ t: e.timeStamp, kind: e.type, trusted: e.isTrusted,
    x: e.clientX, y: e.clientY, pointer: e.pointerType, coalesced });
}

// The key handler never reads e.key or e.code: no key value is stored.
function onKey(e: KeyLike): void {
  rows.push({ t: e.timeStamp, kind: e.type, trusted: e.isTrusted });
}

// On the lab page: addEventListener("pointermove", onPointer) and the same
// for "pointerdown", "pointerup", "keydown", and "keyup".
// Here: a synthetic list of events, made by hand for the example.
const many = (n: number) => () => new Array(n).fill(0);
const synthetic: (PointerLike | KeyLike)[] = [
  { type: "pointermove", timeStamp: 1000.0, isTrusted: true, pointerType: "mouse", clientX: 10, clientY: 20, getCoalescedEvents: many(4) },
  { type: "pointermove", timeStamp: 1016.7, isTrusted: true, pointerType: "mouse", clientX: 18, clientY: 24, getCoalescedEvents: many(3) },
  { type: "pointermove", timeStamp: 1033.3, isTrusted: false, pointerType: "mouse", clientX: 40, clientY: 40, getCoalescedEvents: many(0) },
  { type: "keydown", timeStamp: 1200.0, isTrusted: true },
  { type: "keyup", timeStamp: 1290.0, isTrusted: true },
  { type: "keydown", timeStamp: 1410.0, isTrusted: true },
  { type: "keyup", timeStamp: 1488.0, isTrusted: true },
];
for (const e of synthetic) {
  if ("pointerType" in e) onPointer(e); else onKey(e);
}

for (const r of rows) console.log(JSON.stringify(r));
const untrusted = rows.filter((r) => !r.trusted).length;
const noCoalesced = rows.filter((r) => r.kind === "pointermove" && r.coalesced === 0).length;
console.log(`rows=${rows.length} untrusted=${untrusted} moves-with-no-coalesced=${noCoalesced}`);
const keyRows = rows.filter((r) => r.kind.startsWith("key"));
const keyFields = Object.keys(keyRows[0]).join(",");
console.log(`key-rows=${keyRows.length} key-fields=${keyFields}`);

output

One row for each event, a count of untrusted rows and of moves with no coalesced samples, and the fields of the key rows.

{"t":1000,"kind":"pointermove","trusted":true,"x":10,"y":20,"pointer":"mouse","coalesced":4}
{"t":1016.7,"kind":"pointermove","trusted":true,"x":18,"y":24,"pointer":"mouse","coalesced":3}
{"t":1033.3,"kind":"pointermove","trusted":false,"x":40,"y":40,"pointer":"mouse","coalesced":0}
{"t":1200,"kind":"keydown","trusted":true}
{"t":1290,"kind":"keyup","trusted":true}
{"t":1410,"kind":"keydown","trusted":true}
{"t":1488,"kind":"keyup","trusted":true}
rows=7 untrusted=1 moves-with-no-coalesced=1
key-rows=4 key-fields=t,kind,trusted

I ran the code with the Node runtime and the flag --experimental-strip-types. The third move is the one untrusted row, and it also has no coalesced samples. The key rows hold only the time, the kind, and the trust flag. A key value is personal data when it holds what a person types, thus the recorder never reads it.

failure modes

problemcausecorrection
The detector accepts each trusted event as a person.It reads isTrusted as proof of a person.Use the flag as a first filter, and read the fields, the path, and the time after it.
Your own test tool fails the trust check on your page.The tool sends events with dispatchEvent().Mark the test traffic in your lab, and do not change the rule for real visitors.
A behavior score comes from a flag that the client sets about itself.The probe trusts a self-declared value.Score only raw event samples. Treat a self-declared flag as no data.
The capture holds what users typed.The key handler reads key or code.Record the time and the kind of each key event only.
A field check gives false signals on one device.The device does not report pressure or a pointer type.Accept an empty or default field value, and score the agreement of the fields, not one field.

check questions

  1. Explain what an isTrusted value of true proves about an event, and what it does not prove.

    sample answer

    It proves that the user agent made the event, and that no page script sent it with dispatchEvent(). It does not prove that a person moved the device. OS input passes the check, and a detector must not depend on the flag for protocol input.

  2. Name four event fields or states that a detector reads together with the trust flag.

    sample answer

    The pointer type, the pressure, the coalesced samples from getCoalescedEvents(), and the user activation state of the page.

  3. A page script calls dispatchEvent() to send a click. Which check stops the event first?

    1. The path of the pointer
    2. The trust flag of the event
    3. The time between two actions
    answer

    b. The trust flag of the event

    The isTrusted value of an event from dispatchEvent() is false. The cheap trust check stops the event before the path and the time.

  4. Your lab page records key events. Which fields must each key row hold?

    1. The time, the kind of event, and the trust flag
    2. The key value and the time
    3. The key code, the key value, and the trust flag
    answer

    a. The time, the kind of event, and the trust flag

    A capture of key events records the timing only. A key value can be personal data, because it holds what a person types.

exercise

exercise Do this task in your own lab, with synthetic data only. Use no page of a third party.

The inputs are the seven synthetic events of the code example:

  • 3 rows pointermove, with 4, 3, and 0 coalesced samples
  • 1 of the 3 moves with isTrusted: false
  • 4 key rows, with isTrusted: true
  1. Save the code example in an empty folder of your lab.
  2. Change the isTrusted value of the first key row to false.
  3. Run the code with Node and the flag --experimental-strip-types.
  4. Record the new counts in the summary line.
  5. Write which rows a detector refuses by the trust flag alone.
  6. Write which row also gives a field signal.
sample answer

The answer uses the synthetic list of the code example.

The summary line becomes rows=7 untrusted=2 moves-with-no-coalesced=1. The trust flag alone refuses the third move and the first key row. The third move also gives a field signal, because it is a mouse move with no coalesced samples. The key rows still hold no key value.

sources

  1. Event: isTrusted property, MDN, documentation, read 2026-11-20
  2. Chrome DevTools Protocol, Input domain definition, Google (ChromeDevTools), source code, read 2026-11-20
  3. Pointer Events Level 3, W3C, standard, read 2026-11-20
  4. Pointer events, MDN, documentation, read 2026-11-20
  5. Navigator: userActivation property, MDN, documentation, read 2026-11-20
  6. My model of the input paths into a page and the checks of each path, 2026-11 (not public).
  7. Lab result of this course: the trust flag of protocol input events on a lab page (not public).
  8. Benchmark platform, data (my test system): the list of browser fields that detection scripts read, from the code of these scripts, 2026-06 (not public).