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

Proposal to specify behavior for terminals without touch hardware

From: Gregers Gram Rygg <gregersrygg@gmail.com>
Date: Thu, 12 May 2011 20:29:02 +0200
Message-ID: <BANLkTikZ8cYgUrT4Sj8yUUXepGryodP54Q@mail.gmail.com>
To: public-webevents@w3.org

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:

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.

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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:03:53 UTC