# Behavioral bot detection: mouse movement, typing and timing

> Behavioural bot detection judges a visitor by how it interacts with the page: the shape and speed of pointer movement, the rhythm of typing, touch and scroll patterns, and the time spent on each step. Simple bots produce no events or perfectly regular ones. It works best on forms such as login and checkout, combined with device and network signals.

Category: Bot detection. Level: Intermediate. Updated: 2026-11-24.
Canonical page: https://stopbots.io/learn/detection/behavioral-bot-detection/

Device and network signals describe what a client is. Behaviour describes how it acts once it is on the page. A person reading a product page, filling a login form or picking seats leaves a trail of small, irregular movements and pauses. A script usually leaves no trail at all, or one that is too clean.

## What does behavioural bot detection measure?

Signals fall into four groups.

- Pointer data covers the path between targets, speed and acceleration, pauses, overshoot and correction near a button, where inside the button the click lands, and the time between `mousedown` and `mouseup`.
- Typing data covers dwell time (how long each key is held), flight time (the gap between keys), corrections with backspace, and whether text arrived through a paste.
- Touch and scroll data cover the size of the contact area, swipe curves, scroll momentum and how scrolling relates to what is on screen.
- Timing data covers the time from page load to the first interaction, time to complete a form, the order in which fields were filled, and on the server, the order and spacing of requests across a session.

People follow a pattern described by Fitts's law: the time to reach a target grows with its distance and shrinks with its size, so a hand speeds up, then slows and corrects as it approaches a button. Paths curve, speed rises and falls, and typing rhythm varies with the letters being typed.

## How do bots behave differently from people?

The simplest bots send the form directly over HTTP. The page never loads, so no events exist at all. Scripts that run in a page and call `element.click()` or `dispatchEvent()` produce events whose `isTrusted` property is `false`, as [MDN documents](https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted), which real input never does.

Browser automation tools generate trusted input through the browser's own control interfaces, so `isTrusted` alone does not catch them. Their default behaviour still stands out: the cursor jumps to the exact centre of an element with no path before it, keys arrive at identical intervals, and a whole form is filled in a few milliseconds. The [headless browser detection](https://stopbots.io/learn/detection/headless-browser-detection.md) checks catch many of the same tools from the environment side.

More careful operators add generated curves or replay movement recorded from real people. Those leave statistical traces of their own: the same path repeated across many sessions, curves that are smoother than a hand, or movement that ignores the layout, such as an identical path whether the button sits at the top or the bottom of the screen.

## How do you collect behavioural signals?

Collect timing and shape summaries, never the content of what people type. This script counts pointer movement and keystroke intervals and attaches a summary to the form when it is submitted:

```js
const stats = { moves: 0, path: 0, keys: 0, intervals: [], untrusted: 0 };
let lastPoint = null;
let lastKeyTime = null;

document.addEventListener('pointermove', (e) => {
  if (!e.isTrusted) stats.untrusted++;
  if (lastPoint) stats.path += Math.hypot(e.clientX - lastPoint.x, e.clientY - lastPoint.y);
  lastPoint = { x: e.clientX, y: e.clientY };
  stats.moves++;
}, { passive: true });

document.addEventListener('keydown', (e) => {
  if (!e.isTrusted) stats.untrusted++;
  if (lastKeyTime !== null && stats.intervals.length < 200) {
    stats.intervals.push(Math.round(e.timeStamp - lastKeyTime));
  }
  lastKeyTime = e.timeStamp;
  stats.keys++;
});

document.querySelector('form').addEventListener('submit', (e) => {
  const field = document.createElement('input');
  field.type = 'hidden';
  field.name = 'behaviour';
  field.value = JSON.stringify({ ...stats, sinceLoad: Math.round(performance.now()) });
  e.target.appendChild(field);
});
```

On the server, useful starting rules are: untrusted pointer events, a form submitted less than about two seconds after the page loaded, and a spread of keystroke intervals close to zero over 20 or more keys. Tune each threshold on your own traffic. Some password managers and browser extensions dispatch synthetic keyboard or input events when they fill a form, so untrusted keyboard events from real users do occur and should only add weight. Anything sent from the browser can be forged by a bot that has studied your script, so treat a missing or impossible summary as evidence and a plausible one as weak evidence of a human. This is why commercial collectors obfuscate their scripts and payloads and change them often.

## Where does behavioural detection fail?

Many real people do not behave like the average mouse user:

- People on touch screens, keyboard-only users, screen reader users, and people using switch access or voice control produce few or no pointer events.
- Password managers and browser autofill fill fields with no keystrokes, and people paste long passwords.
- A reader who opens an article and scrolls produces almost no data, so content pages give little to judge.

None of these people should be treated as bots just because their behaviour looks unusual. Absent behaviour on a login form, together with a contradiction in the device data, is a much stronger signal than either alone.

Privacy matters too. Keystroke timing and movement patterns can identify people, and in the EU, data processed to identify a person by physical or behavioural traits can count as biometric data under the GDPR. Keep raw traces short-lived, store summaries, and document the security purpose.

## Where does behaviour fit with other signals?

Behaviour arrives late. It needs the visitor to interact, so it cannot judge the first request of a visit. It is strongest at the steps where a person must interact before the decision: login, signup, checkout and [form submissions](https://stopbots.io/learn/ad-fraud/how-to-stop-form-spam.md). There it can replace a visible puzzle, which is the idea behind many [CAPTCHA alternatives](https://stopbots.io/learn/captcha/captcha-alternatives.md), and it adds weight to an [invisible JavaScript challenge](https://stopbots.io/learn/captcha/javascript-challenges-explained.md). The overview in [how bot detection works](https://stopbots.io/learn/detection/how-bot-detection-works.md) shows how it combines with device, network and history signals. For the payment step, see Kairal's guide to the [best fraud signals for checkout](https://www.kairal.io/blog/best-fraud-signals-for-checkout/).

## Common questions

### Can mouse movement detect bots?

It catches automation that moves the cursor in straight lines, at constant speed or not at all. Bots that replay recorded human movement can pass a mouse check, so mouse data works as one weighted signal and fails as a single gate.

### Does behavioural bot detection work on mobile?

Yes, with different signals. Phones produce touch events with contact size, swipe curves and scroll momentum, and some browsers expose motion sensors, in some cases only after a permission prompt. Mouse-based models do not transfer, so mobile traffic needs its own thresholds.

### What is invisible bot detection?

It is detection that runs without asking the visitor to do anything, using browser checks, background JavaScript challenges and behaviour collected while the person uses the page normally. The visitor only sees a challenge when those signals are not enough to decide.

## Related

- [How does bot detection work?](https://stopbots.io/learn/detection/how-bot-detection-works.md)
- [CAPTCHA alternatives: how to stop bots without a puzzle](https://stopbots.io/learn/captcha/captcha-alternatives.md)
- [How invisible JavaScript challenges work](https://stopbots.io/learn/captcha/javascript-challenges-explained.md)
- [How to stop bots from submitting forms](https://stopbots.io/learn/ad-fraud/how-to-stop-form-spam.md)
