first, I know there are a few ways around this, such as making making the ontouchstart and onclick the same. But is there a way to check if the users has a smartphone/tablet/touchscreen device vs a laptop or computer, and change the function of ontouchstart to click? Here's an example of one way to solve it:
var touchScreen = false;
var touches = 0;
var clicks = 0;
document.addEventListener("touchstart", function() {
  touchScreen = true;
  function touch() {
    touches++;
    console.log(touches);
    console.log(clicks);
    document.getElementById("clicks").innerHTML = "touches = " + touches + ", clicks = " + clicks;
  }
  touch();
});
function click() {
  if (touchScreen === false) {
    document.addEventListener("click", function(event) {
      clicks++;
      console.log(touches);
      console.log(clicks);
      document.getElementById("clicks").innerHTML = "touches = " + touches + ", clicks = " + clicks;
    });
  }
}
click();html {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}<h1><span id="clicks"></span></h1>This code snippet shows that I've "identified" if it's a touchscreen device or not, and executed something based on that info. (FYI when you run code snippet make sure to click/tap on the blank space to receive an output)
However, I don't want to do this because I have many functions that rely on things such as <button onclick="click()">click</button>. I'd like to figure a simple way to just change the onclick part to ontouchstart if it's a touchscreen device. I use JavaScript for my scripting only, Thanks!
Also if you believe there is no way to do so, would there be a better way to check and execute code (with a click or touch) based on if the user has a touchscreen or other device?
edit:
I would normally just do click but some of the items on the page will probably be clicked at a fast rate, or at least faster than 300ms
 
     
    