Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tap #28

Open
FeXd opened this issue Feb 10, 2024 · 1 comment
Open

Tap #28

FeXd opened this issue Feb 10, 2024 · 1 comment

Comments

@FeXd
Copy link
Owner

FeXd commented Feb 10, 2024

We should use "tap" instead of "click" when on mobile device.

@FeXd
Copy link
Owner Author

FeXd commented Feb 17, 2024

Was doing some searching and came across a few possible techniques. There is going to always be an edge case but I feel like we could at least cover some of the easy ones.

function detectDeviceType() {
  if (window.navigator.maxTouchPoints > 0) {
    console.log("User is on a touch device.");
  } else {
    console.log("User is on a device with a mouse.");
  }
}

detectDeviceType();

Or possibly

function detectInputMethods() {
  const hasTouch = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
  const hasMouse = 'onmousemove' in window;
  const hasPointer = window.PointerEvent || window.MSPointerEvent; // Check for PointerEvent (modern browsers) or MSPointerEvent (IE)

  console.log(`Touch support: ${hasTouch}`);
  console.log(`Mouse support: ${hasMouse}`);
  console.log(`Pointer support: ${hasPointer}`);
}

detectInputMethods();

Really trying to find a simple solution that doesn't require library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant