Read more

How to detect touch-capable browsers

Dominik Schöler
February 18, 2015Software engineer at makandra GmbH

The easiest way to detect touch-capable browsers is to check for the presence of touch events. It is no 100% solution, but has by far the best cost-benefit ratio. (Know that this does not detect touch devices, but browsers.)

Javascript

var isTouchDevice = 'ontouchstart' in window

Coffeescript

isTouchDevice = 'ontouchstart' of window
Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

On the difference between the Javascript and the Coffeescript version, see Beware: Coffeescript "in" is not the Javascript "in".

Posted by Dominik Schöler to makandra dev (2015-02-18 14:30)