Skip to content

Instantly share code, notes, and snippets.

@sayyedhammadali
Created October 3, 2021 09:32
Show Gist options
  • Save sayyedhammadali/a8c82b2501c5c82b869312f08d90340b to your computer and use it in GitHub Desktop.
Save sayyedhammadali/a8c82b2501c5c82b869312f08d90340b to your computer and use it in GitHub Desktop.
Check if the current user has touch events supported
const touchSupported = () => {
('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch);
}
console.log(touchSupported());
// Result: will return true if touch events are supported, false if not
@kyvg
Copy link

kyvg commented Oct 11, 2021

should be:

const touchSupported = () => (
  'ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch;
)

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