GitHub 6248★

Check if the touch events are supported

JavaScript version

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

TypeScript version

const touchSupported = (): boolean => (
'ontouchstart' in window || (window as any)['DocumentTouch'] && document instanceof (window as any)['DocumentTouch']
);
Follow me on and to get more useful contents.