Proposal to specify behavior for terminals without touch hardware

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.

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.

Cheers,
Gregers

Received on Thursday, 12 May 2011 18:29:31 UTC