# maxTouchPoints vs ontouchstart: four ways to ask about touch

> maxTouchPoints counts touch points; ontouchstart says whether touch events exist. Two media queries also answer, and one changed alone contradicts them.

Source: https://mosaicbrowser.com/blog/maxtouchpoints-four-routes

## A touch screen has four routes, and spoofing one is a contradiction

maxTouchPoints counts touch points; ontouchstart says whether touch events exist. Two media queries also answer, and one changed alone contradicts them.

![4: Four routes to one touch screen, beside a screenshot: a profile fingerprint in Mosaic: GPU, screen, fonts, timezone and language matched to the proxy’s IP](https://mosaicbrowser.com/covers/maxtouchpoints-four-routes.webp)

`navigator.maxTouchPoints` and `'ontouchstart' in window` answer two different questions about the same screen. `maxTouchPoints` is a count: how many fingers the device can track at once, 0 when there is no touch screen and 10 on a typical touch laptop. `ontouchstart` is a yes or no: does this browser expose touch events at all. Two CSS media features, `pointer` and `hover`, answer a third question, how the person points. On a real machine all of them agree, because they all come from the same hardware.

That agreement is what makes touch a trap for anyone changing a fingerprint. Change one route and leave the others alone and a page does not need a database to catch it. It only has to ask twice.

## maxTouchPoints vs ontouchstart: what each one reads

Here are the routes a page has, and what each one costs it to read:

| Route | What it says | How a page reads it |
| --- | --- | --- |
| `navigator.maxTouchPoints` | number of touch points | one property |
| `'ontouchstart' in window` | touch event API present | one property check |
| `(pointer: coarse)`, `(any-pointer: coarse)` | primary pointer, and any pointer, is a finger | `matchMedia()` or CSS |
| `(hover: none)`, `(any-hover: none)` | the pointer cannot hover | `matchMedia()` or CSS |

Every one of these is free, synchronous and silent. None asks permission, and none shows up as anything unusual in a page's network traffic. A media query does not even need script, because a stylesheet can load a different background image for `(pointer: coarse)` and the server sees which one was fetched.

The real answers differ by machine, and the combinations are what a page compares:

| Machine | maxTouchPoints | ontouchstart | primary pointer | also available |
| --- | --- | --- | --- | --- |
| Desktop or Mac laptop | 0 | no | fine, can hover | nothing else |
| Windows touch laptop | 10 | yes | fine, can hover | coarse, no hover |
| Android phone | 5 on the phones we captured | yes | coarse, no hover | nothing else |

A touch laptop is the row people get wrong. It has a trackpad *and* a screen, so its primary pointer is fine and it can hover, while `any-pointer: coarse` and `any-hover: none` are also true. Treating it as a big phone is as wrong as treating it as a desktop.

Mosaic is a desktop app

Email yourself the link and open it on your computer.

[How it works: Machines that exist](https://mosaicbrowser.com/features/real-fingerprints)

## Spoofing maxTouchPoints alone

Our generator draws a Windows machine with ten touch points 18 per cent of the time. macOS profiles are always 0, and the generator's own audit flags anything else ("macOS desktops report maxTouchPoints = 0"), since Apple does not sell a Mac with a touch screen. An Android profile that reports none is flagged too.

The engine claims the count inside the engine. Our change makes `NavigatorEvents::maxTouchPoints` return the value of `--fingerprint-max-touch-points`, and that is all it does. It deliberately leaves the `TouchEvent` constructor alone. Chromium already ships it on every desktop build, so gating it would create the mismatch the change is meant to prevent.

Now run that ten-point profile on a machine with no touch screen. `maxTouchPoints` says 10. `ontouchstart` says no. `(any-pointer: coarse)` says no. `(any-hover: none)` says no. One route claims a touch laptop and three describe a desktop, which is a device nobody owns. We found this one by reading Blink for every other caller of the same hardware fact after changing the obvious one, and it was one of five values in the engine with a second route nobody had looked for. The `deviceMemory` client hint was another ([the header that read the real memory](https://mosaicbrowser.com/blog/sec-ch-device-memory-header)).

## The fix was two switches Chromium already has

We did not write a second engine change. Chromium has its own switches for both of the other routes, and they move the media-query engine rather than an accessor, which is more coherent than anything we would have added ourselves:

- `--touch-events=enabled` or `disabled` decides whether the touch event API exists, so `ontouchstart` follows the claim.
- `--blink-settings` sets `primaryPointerType`, `availablePointerTypes`, `primaryHoverType` and `availableHoverTypes`, which are what the `pointer`, `any-pointer`, `hover` and `any-hover` queries are computed from.

The values are bitmasks: for pointers none is 1, coarse 2 and fine 4; for hover none is 1 and hover 2. A Mosaic profile with no touch points launches with a fine pointer only (4) and hover only (2). A touch laptop profile gets a fine primary pointer with fine and coarse available (6), and hover with both hover and no-hover available (3). An Android profile gets coarse only (2) and no hover (1).

We set them in both directions, and that half is easy to miss. A profile claiming zero touch points on a computer that does have a touch screen would otherwise report a coarse pointer beside a count of 0, the same contradiction the other way round. On a machine that already matches the claim, forcing these values changes nothing.

Before trusting either switch name we checked it with `strings` against the engine binary, because Chromium accepts a switch it does not know without a word, and a misspelt one looks exactly like a working one.

## The phone case, measured

The first live Android profile showed why the phone is its own row. It reported `maxTouchPoints` 5 and `ontouchstart` present, and still answered **false** to `(pointer: coarse)` and **false** to `(hover: none)`, because the pointer values were written for the desktop case. Five touch points beside a fine pointer that hovers is not a phone and not a laptop.

A phone has no fine pointer and cannot hover, so its primary and available sets are now coarse and none, and nothing else. The [model client hint](https://mosaicbrowser.com/blog/sec-ch-ua-model-header-android) is another place an Android profile has to agree with itself, and the rest of what a profile is drawn from is in [real fingerprints](https://mosaicbrowser.com/features/real-fingerprints).

## How to check your own profile

Paste this into the console of any page and compare it with the table above:

```
({
  maxTouchPoints: navigator.maxTouchPoints,
  ontouchstart: 'ontouchstart' in window,
  coarse: matchMedia('(pointer: coarse)').matches,
  anyCoarse: matchMedia('(any-pointer: coarse)').matches,
  hoverNone: matchMedia('(hover: none)').matches,
  anyHoverNone: matchMedia('(any-hover: none)').matches
})

```

If `maxTouchPoints` is above 0 and `anyCoarse` is false, or the count is 0 and `ontouchstart` is true, something changed one route and not the others.

## Questions

### What is the difference between maxTouchPoints and ontouchstart?

navigator.maxTouchPoints is a number: how many simultaneous touches the device supports, 0 on a machine with no touch screen. 'ontouchstart' in window is a yes or no: whether the browser exposes the touch event handlers at all.

### Which should I use to detect a touch device?

For layout, the pointer and hover media queries, because they say how the person will actually point. maxTouchPoints greater than 0 says touch is possible. A touch laptop has both a trackpad and a touch screen, so no single answer covers it.

### What does a touch laptop report?

maxTouchPoints of 10 and touch events present, a fine primary pointer with hover because the trackpad is the primary pointer, and also a coarse pointer and no-hover among the available ones, because the screen is there too.

### How does Mosaic set touch values?

The engine's own switch claims maxTouchPoints, and at launch Chromium's --touch-events and --blink-settings switches set the touch API and the pointer and hover types from the same claim, so all four routes agree.

## Related

[Machines that exist: fingerprints drawn from real hardware](https://mosaicbrowser.com/features/real-fingerprints): Mosaic draws each profile's GPU, screen, CPU, memory and fonts from one real device, so the parts of a fingerprint agree with each other and with the host.

[Browser fingerprint: what a site can read about your machine](https://mosaicbrowser.com/glossary/browser-fingerprint): A browser fingerprint is the set of values a site reads about your browser and computer, which together recognize you without cookies. What goes into one.

[deviceMemory and Sec-CH-Device-Memory are one number read twice](https://mosaicbrowser.com/blog/sec-ch-device-memory-header): Chrome builds the Sec-CH-Device-Memory header from the same function as navigator.deviceMemory, so a change on the script side alone sends the real figure.

[Sec-CH-UA-Model is empty on a desktop and a phone's name on Android](https://mosaicbrowser.com/blog/sec-ch-ua-model-header-android): Sec-CH-UA-Mobile goes out unasked; Sec-CH-UA-Model only after a site sends Accept-CH. A desktop's model is empty, and so was our first Android one.

[Your dark mode is sent as a request header](https://mosaicbrowser.com/blog/sec-ch-prefers-headers): Sec-CH-Prefers-Color-Scheme sends your dark mode setting to any server that asks. On our profiles it carried this Mac's own settings, until each drew its own.







[Why we built our own Chromium instead of injecting JavaScript](https://mosaicbrowser.com/blog/why-we-built-our-own-chromium): Mosaic changes fingerprint values inside its own engine. Three measured differences between Chrome and plain Chromium explain why that matters.

## Mosaic, on your own computer

The browser this blog is about: its own Chromium, fingerprints from real machines and a proxy IP per profile. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

Mosaic is a desktop app

Email yourself the link and open it on your computer.
