The only way to detect touch with JavaScript
David Gilbertson
68020

Great article, thanks. What you think about doing it this way (jQuery):

  • find out if device is touch capable
  • if yes, then add event listeners for touchstart and mouseover
  • remove event listeners when either of those are found

This way event listeners are not uset at all for devices that are not touch capable. Another option would be to use only those listeners with .one(), not sure which one would be lighter for browser.

Like what you read? Give Riku a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.