Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #8364
| Date | 2011-11-16 13:53 +1100 |
|---|---|
| From | Andrew Poulos <ap_prog@hotmail.com> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: detecting !mouse |
| References | <fu6dnREJhvYbSlzTnZ2dnUVZ_g-dnZ2d@westnet.com.au> <wuidnVSChY2Uwl_TnZ2dnUVZ_gednZ2d@westnet.com.au> |
| Message-ID | <Vs2dnTUCnZ4GuF7TnZ2dnUVZ_sydnZ2d@westnet.com.au> (permalink) |
On 15/11/2011 11:45 PM, RobG wrote:
> On 15/11/11 1:07 PM, Andrew Poulos wrote:
>> Ok, I can't user window.touch, or its variants, to confidentially
>> determine if a device is actually touch capable. But would it be safe to
>> assume that a device that returns 0 for
>> event.clientX || e.pageX, and event.clientY || e.pageY
>> does *not* have a mouse attached?
>
> Not sure it's safe to assume that because the cursor reports its
> position as (0,0) at some random instant in time that the device doesn't
> have a mouse attached and therefore suports touch events.
>
> Actually it's quite a leap of faith.
>
> Just because a device supports touch events doesn't mean that no mouse
> (or other pointing device) is attached, or that the user is only using
> touch events. What about keyboard navigation?
>
> A much better strategy is to test for touch support explicitly. Some
> time ago (years) I wrote the following:
>
> function touchSupported() {
> if (document && document.createEvent) {
> try {
> document.createEvent('TouchEvent');
> return true;
> } catch (e) {
> return false;
> }
> }
> }
My desktop computer (non touch-capable) returns false and my ipad and
Android phone both return true. So, so far so good.
> but have since lost interest in writing touch-specific scripts. Use it
> at your peril. Maybe there is something in DM's MyLibrary?
Thanks, I didn't notice anything in DM's library.
If a device supports touch events does that also include swipes ie.
single-finger gestures? Or are swipes considered gestures?
Andrew Poulos
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
detecting !mouse Andrew Poulos <ap_prog@hotmail.com> - 2011-11-15 14:07 +1100
Re: detecting !mouse Andrew Poulos <ap_prog@hotmail.com> - 2011-11-15 16:42 +1100
Re: detecting !mouse Swifty <steve.j.swift@gmail.com> - 2011-11-15 10:54 +0000
Re: detecting !mouse Gregor Kofler <usenet@gregorkofler.com> - 2011-11-15 11:04 +0100
Re: detecting !mouse RobG <rgqld@iinet.net.au> - 2011-11-15 22:45 +1000
Re: detecting !mouse Andrew Poulos <ap_prog@hotmail.com> - 2011-11-16 13:53 +1100
csiph-web