Device supports touch events

Angelos Chalaris · JavaScript, Browser · Oct 22, 2020

Checks if touch events are supported.

  • Check if 'ontouchstart' exists in the Window.
const supportsTouchEvents = () =>
  window && 'ontouchstart' in window;
supportsTouchEvents(); // true

Recommended snippets