Check if the touch events are supported

True when the browser exposes touch events or reports touch points.

JavaScriptBrowser · DOM Version 1.0.0 · MIT · .md

check-if-the-touch-events-are-supported.js
function touchSupported() { return 'ontouchstart' in window || navigator.maxTouchPoints > 0; }

Usage

usage.js
// Desktop Chromium without a touchscreen:
touchSupported(); // → false
matchMedia('(pointer: coarse)').matches; // → false

Lines marked → were executed in headless Chromium against the markup above, and each result was compared with the value shown. Lines marked e.g. are illustrative.

Know the limits

  • Touch support is not touch use: many laptops have both. For layout, the pointer and hover media features describe the primary input, as the last line shows.
  • The original also checked DocumentTouch, an obsolete non-standard interface; maxTouchPoints is the standard signal.

The function above is the code the usage lines run. It does not validate its arguments; add checks where it receives untrusted input.

Source & maintenance

Based on Check if the touch events are supported from the original 1loc collection by Nguyen Huu Phuoc. Copyright (c) 2020 phuoc-ng. MIT licensed.

Uses navigator.maxTouchPoints instead of the obsolete DocumentTouch. Executed in Chromium. Original MDX retained as inert source evidence.

Maintained by Oveyon. Source commit: 14b481cf60df. Read the license.

Usage lines executed in headless Chromium against the fixture markup; no external services · reviewed October 28, 2026.

Keep exploring

Type two or more characters. Try “duplicate”, “webhook” or “retry”.