Skip to content

Latest commit

 

History

History
18 lines (14 loc) · 454 Bytes

supportsTouchEvents.md

File metadata and controls

18 lines (14 loc) · 454 Bytes
title tags
supportsTouchEvents
browser,intermediate

Returns true if touch events are supported, false otherwise.

  • Check if ontouchstart exists in window or window.DocumentTouch is true and the current document is an instance of it.
const supportsTouchEvents = () =>
  window &&
  ('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch);
supportsTouchEvents(); // true