I am developing a webapp that will be deployed on various devices, ranging from desktops, to Android mobiles, to Blackberry mobiles. Having to support such different devices, two different interfaces exist: touch and not touch.
The problem is that Blackberry devices without touch support, such as the Blackberry 9300, incorrectly appear to support touch events. Namely,
'ontouchstart' in window;
returns true
.
Until now, I just relied on browser sniffing, as bad as it is:
if (window.navigator.userAgent.match(/BlackBerry/i)) {
doStuff();
}
But now I have to support the Blackberry Torch, which is touch, so the latter will not work anymore. Of course I could try a more precise regex for browser sniffing, but I feel I am going down the way of perdition.
Is there a more reliable way to detect support for touch events, that will work on Blackberry devices too?