I am currently experiencing some issues with some touch detection in a plugin i am using.
The plugin uses the following code
touch = ("ontouchstart" in window) || window.DocumentTouch && document instanceof DocumentTouch;
eventType = (touch) ? "touchend" : "click";
To determine if it should use touchend or click event on some gallery navigation.
However unfortunately when accessing the page using a Blackberry 9300 running os 6.0 its falsely reported as being a touch enabled device and event doesn’t fire.
I’ve checked the detection method used and its the same as the one in Modernizr.
Does anyone have a solution to this issue?
According to Paul Irish, RIM said this about the issue:
See these (currently open) tickets at github/Modernizr for possible work-arounds and the lastest detection code and then try to alter your plugin as needed. You might need to specifically detect blackberry if the latest detection code below doesn’t work.
Also check this touch test out, the browserscope tab indicates blackberry 9000 has been detected as false, so worth a shot to test it in your device too. http://modernizr.github.com/Modernizr/touch.html
The latest modernizr source for the touch detect appears to have an addition of an @media detection in addition to your code you posted.
BlackBerry/PlayBook UA sniffing
To specifically detect a BlackBerry devices using the user agent string and borrowing from solutions given from here and here I whipped up this little function which you can test and see working on jsbin at http://jsbin.com/aliwur/1/edit#javascript,live and it should parse out Blackberry 5.0/4.0/6.0 and Playbook from the user agent strings:
Of course that might be more then you need so to simplify it to only “Blackberry 9300 6.0” I guess you could also just do this:
For a better all purpose User Agent parsing see ua-parser
https://github.com/tobie/ua-parser/