I found Detecting touch devices and detecting 'can hover' with JavaScript in 2020 which is basically the same as What's the best way to detect a 'touch screen' device using JavaScript?. The asker acknowledges the previous posts, but claims the new question is needed:
This post here suggest a bazillion different ways to solve this. But it's now 2020 - and a lot has happend across browsers and devices, so I figured I would draw a line in the sand and start a new question.
Many of the answers doesn't consider all corner cases:
- Like stylus'es
- Like Apple's magic mouse that (apparently) emulated touch events (I heard of this, I haven't experienced it myself).
- Like the new iPad Pro, which emulates a Macbook Pro's Safari.
- Like if the capability changes, so the user gains/loses the ability to 'touch' (Like when enabling mobile-view with Chrome Developer tools).
Should this post be flagged/closed as duplicate, or is it justified? Given that answer on the older post are being updated, I personally would flag this specific post.