Skip to content

Conversation

@blackbing
Copy link

@blackbing blackbing commented Jan 5, 2024

("ontouchstart" in document.documentElement) will return false on Desktop Chrome even if it support touch.

Refer to other repo, they use navigator.maxTouchPoints > 0 to detect if the device supports touch.
https://github.com/microsoft/vscode/blob/f873eb102260dcbdd0c4068a59f21c1ef91697bd/src/vs/base/browser/touch.ts#L127C3-L127C3

the demo also does not work on Desktop Chrome with a touch device. I've tried it on other browsers, and this way is more accurate.

also check caniuse:
Screenshot 2024-01-05 at 9 40 47 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants