frank_conijn — 2013-02-19T08:08:50-05:00 — #1
We have to consider that the use of touchscreens is on the rise and that we may have to adapt our code to that. For example, menu items and other links will have to have a great enough touch margin. But that can have unwanted aesthetic effects. Is there a way to detect that a visitor uses a touchscreen, so that we can cater to that only when needed?
pullo — 2013-02-19T08:23:02-05:00 — #2
frank_conijn — 2013-02-19T08:33:14-05:00 — #3
Thanks, Pullo. I thought chances were so slim that I didn't bother searching the net, but went straight to the specialists here with that question. But it is quite possible. I only hope that it is cross-browser, and then I mean the rather unreliable proprietary browsers that many touch devices have.
But still, thanks.
pullo — 2013-02-19T08:34:42-05:00 — #4
I was also pleasantly surprised to find out how easy it is.
(Although be aware, Modenizr is sometimes prone to false positives)
ralphm — 2013-02-19T08:42:22-05:00 — #5
I'm not sure of the exact correspondence of touch screens to @media query recognition, but you can target more advanced smart phones with CSS @media rules, so that might be the answer to your need here.
On the horizon, we will soon be able to detect all sorts of things, like how much bandwidth the device is currently supporting and how much charge its battery has. So presumably there will be ways of detecting if there is touch functionality, too (if not already). It just may not be necessary for what you want to do here. CSS3 is the easy way.
Had this post open for longer than I realized. Lots of answers posted in the mean time, so this may not be relevant.