detect if touch device js code example

Example 1: javascript detect touch screen

function isTouchScreendevice() {
    return 'ontouchstart' in window || navigator.maxTouchPoints;      
};

if(isTouchScreendevice()){
    alert("I am a touch screen device")
}

Example 2: javascript detect touch

/* npm i tappify */
import Tappify from "tappify";

/* Only works in react.js */
function myComponent() {
  return <>
    <Tappify.Finger>
      Client is using finger *tap tap*
    </Tappify.Finger>
 
    <Tappify.Cursor>
      Client is using mouse cursor *click click*
    </Tappify.Cursor>
  </>
}
//more info: https://github.com/asplunds/tappify