W3C home > Mailing lists > Public > public-webevents@w3.org > April to June 2011

Re: Proposal to specify behavior for terminals without touch hardware

From: Olli Pettay <Olli.Pettay@helsinki.fi>
Date: Thu, 12 May 2011 21:56:05 +0300
Message-ID: <4DCC2D45.5080009@helsinki.fi>
To: Gregers Gram Rygg <gregersrygg@gmail.com>
CC: public-webevents@w3.org
On 05/12/2011 09:29 PM, Gregers Gram Rygg wrote:
> Hi,
>
> Many web developer are already using javascript touch events to detect
> if the terminal has touch hardware (not stylus). This is useful to
> give the user a better user experience with finger-size-friendly
> clickable elements, but also to use different controllers in more
> advanced javascript applications. It's not the perfect solution, but
> it's the only one we have that works reliably at the moment (I don't
> regard UA-sniffing as reliable). When Chromium implemented touch
> events (http://code.google.com/p/chromium/issues/detail?id=36415),
> many of the detection methods gave false positives. Chromium decided
> to revert, but I hope this can be mentioned in the spec so other
> browser developers are aware of the issue.
>
> An example:
> if ("ontouchstart" in window) {
>      // terminal has touch
> } else {
>      // terminal does not have touch
> }
>
> Paul Irish have collected the different detection methods he could
> find, and created a test page to find out how they behaved in
> different browsers. It explains the detection methods in use, and the
> result of each in different browsers:
> http://modernizr.github.com/Modernizr/touch.html
>
> Web developers need some way of detecting touch hardware, so I propose
> this behavior should be specified in the spec. I'm not very good at
> writing text for specs, but I'll give it my best shot so you have
> something to start with:
>
> When the terminal does not have touch hardware:
> - The touch event properties (ontouchstart, ontouchmove, etc.) MUST
> NOT be exposed on Element, Window nor Document.
> - document.createEvent("TouchEvent") MUST throw an Error.
> Developers are using this to detect if a terminal has support for
> touch hardware.

Yeah, would be good to say something about this.
But I'm not sure which feature detection mechanisms should be supported.

Note, seems like chromium doesn't properly hide
TouchEvent interface on non-touch-hardware.
data:text/html,<script>alert('TouchEvent' in window);</script>
should be false, but Chromium gives true.
Desktop Firefox gives false, but touch-enabled Fennec true.


>
> A more complicated problem is when a terminal have both touch and
> mouse hardware, but I guess that is out of scope for this spec.

It has been discussed, and even if it might be out of scope of the
spec, it is still, IMO, good to think about.

-Olli



>
> Cheers,
> Gregers
>
>
Received on Thursday, 12 May 2011 18:56:33 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 12 May 2011 18:56:34 GMT