Twitter | Search | |
Jeremias Menichelli Feb 18
Replying to @stefanjudis @Media
Wait, can this be used in combination with window.matchMedia to detect a touch device then? 🤔
Reply Retweet Like
Stefan Judis Feb 18
Replying to @jeremenichelli @Media
I guess so! 🙈
Reply Retweet Like
patrick h. lauke Feb 18
this needs an update, but: don't fall for apparently easy "can i detect touch devices" things (comes down to problems with multi-input devices - like a phone, but with paired mouse, or a "desktop" device, but with a touchscreen)
Reply Retweet Like
patrick h. lauke Feb 18
(noting that one section of that old article is now obsolete, due to changes in the final mq5 spec, while other parts have been extensively clarified - by me - in the spec as notes/tweaks as well)
Reply Retweet Like
patrick h. lauke Feb 18
related, from the JS side
Reply Retweet Like
Stefan Judis Feb 18
Thanks Patrick! Will check the resources. 😊
Reply Retweet Like
patrick h. lauke Feb 18
tl;dr: testing for "hover" only tells you "does whatever the browser/device think is its primary input support hover?". nothing more. could be more inputs. mitigate a bit by testing "any-hover". but even then, it doesn't reflect necessarily what the user is using right now
Reply Retweet Like
patrick h. lauke Feb 18
in general, don't try to "detect" touch devices. design so it works for touch/mouse/stylus/keyboard. if you must, use whatinput.js or similar to check/guess the origin of the latest event
Reply Retweet Like
patrick h. lauke
obligatory link to my (slightly outdated) magnus opus - oh, and my own take on a naive "detect presence of a touchscreen" script (using, in one part, "any-pointer" CSS mq)
Reply Retweet Like More
Stefan Judis Feb 18
This is great! I'll adjust the short article and resources after further reading.
Reply Retweet Like