Re: [whatwg/dom] document.createEvent() should maybe not be conditional upon exposure (#952)

> I don't have a concrete proposal, but it seems Firefox's behavior would allow you to detect touch support across all browsers, whereas what Chrome shipped defeats that? Maybe that's okay though.
> 
> I should also note that since I filed OP I learned that a simple flag as suggested in [w3c/touch-events#64](https://github.com/w3c/touch-events/issues/64) might not be enough (as your table also shows), depending on which way we go.

We used to enable / disable touch API's based on the existence of a touchscreen but ran into the issues @RByers mentioned above.

> @RByers Is the anyway in desktop Chrome to detech touch support? Perhaps using navigator.maxTouchPoints ?

This does indeed reflect [whether Chrome currently believes it has a touchscreen attached](https://source.chromium.org/chromium/chromium/src/+/master:ui/base/pointer/pointer_device.h;l=35?q=MaxTouchPoints%5C(%5C)%20file:pointer_device.h&ss=chromium%2Fchromium%2Fsrc) however it can change dynamically when you attach a touchscreen or enable touch emulation in dev tools. I've noticed the detection can also can be a little flaky (on my ChromeOS Linux container running desktop Chrome Linux it claims 0 even though it fires touchevents).

As @RByers mentioned we encourage developers to handle both types of events and use media queries to determine whether they should size elements for touch or not. Note that the pointer / hover media queries effectively answer the opposite question, does the user have a mouse capable of hovering, you can use any-pointer / any-hover as @patrickhlauke noted in his article, optionally using window.matchMedia to observe changes to these queries, e.g. https://jsbin.com/daqedes/edit?js,output

P.S. apologies if this no longer adds value, other replies came in while I was still writing this :-)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/952#issuecomment-795703217

Received on Wednesday, 10 March 2021 16:36:54 UTC