js detect mouse support

JavaScript
if (matchMedia('(pointer:fine)').matches) {
  // Device has a mouse
}

Source

Also in JavaScript: