Feature Detection Touch events

A lot of people think that using the navigator agent to detect mobile / desktop is not correct. They swear by feature detection instead…and I suppose they have a point.

Here is a simple function which will allow touch events to work on both mobile and desktop devices.

Update: I recently found the above code not working as well as I wanted on some projects. I found another good way to use touchstart when available is like so:

Going forward I will use this.