# Check if the touch events are supported

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

Canonical: https://1loc.dev/dom/check-if-the-touch-events-are-supported/
Version: 1.0.0
Runtime: JavaScript · modern browsers (DOM)
Verification: Usage lines executed in headless Chromium against the fixture markup; no external services
Updated: 2026-10-28

## Implementation

```javascript
function touchSupported() { return 'ontouchstart' in window || navigator.maxTouchPoints > 0; }
```

## Usage

```javascript
// 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.

## 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 does not validate its arguments. Add checks where it receives untrusted input.

## Source and license

Original: https://github.com/phuocng/1loc/blob/14b481cf60dff1620ab1bb99a43b1f68068cdd9b/contents/check-if-the-touch-events-are-supported.mdx
Author: Nguyen Huu Phuoc and original contributors
Contributors: See original repository history
Source commit: 14b481cf60dff1620ab1bb99a43b1f68068cdd9b
Copyright (c) 2020 phuoc-ng
License: MIT — https://1loc.dev/licenses/
Maintainer: Oveyon
Modifications: Uses navigator.maxTouchPoints instead of the obsolete DocumentTouch. Executed in Chromium. Original MDX retained as inert source evidence.
