ten1seven / what-input

A global utility for tracking the current input method (mouse/pointer, keyboard or touch).
https://ten1seven.github.io/what-input
MIT License
1.35k stars 89 forks source link

Touch screen being registered as mouse on iPhone #54

Closed danielpost closed 7 years ago

danielpost commented 7 years ago

Hi there,

I'm using Safari on an iPhone 7 running iOS 10.2. When touching the list items on the demo page the touches get registered correctly, however when holding down the list items any longer than a brief touch and then releasing them they get registered as mouse clicks. Any idea what might cause this?

Thanks!

ten1seven commented 7 years ago

Hi @danielpost,

It makes sense because touch and "mouse" events are intermingled in iOS. So a long touch can be interpreted as a click because iOS waits to see if you're scrolling or swiping. However, I'm attempting to buffer that out here (though it might be more effective to stop the buffer with touchend rather than a timer): https://github.com/ten1seven/what-input/blob/master/src/what-input.js#L186

I'm running iOS 10.1 on an iPhone SE and haven't been able to reproduce the issue you're seeing. If there's any other info you can send me I'm game for trying to get it worked out.

danielpost commented 7 years ago

That makes sense. What other info would you need? I can reproduce it fairly reliably on my phone, but not on Chrome's dev tools for example.

EDIT: To clarify, this isn't currently causing any issues for me but I figured it might be something you'd want to fix if possible.

ten1seven commented 7 years ago

I just uploaded a possible fix per my thought about using touchend (v4.1.0). Can you take a look at the demo page and see if there's any difference for you?

danielpost commented 7 years ago

@ten1seven I can't reproduce it on my phone anymore. Nice one!

ten1seven commented 7 years ago

Thanks @danielpost! I'm going to close this ticket but please send me anything else you come across.

birdkiwi commented 6 years ago

I still can reproduce "mouse" click event on iPhone. Just keep clicking on buttons or links and it appears randomly. Also, "mouse" event firing when holding for 1 sec. Reproduces in simulator and real devices.

iOS 10.3.1 & iOS 11.2

2017-12-14_12-54-10

ten1seven commented 6 years ago

Hi @birdkiwi! You must have a tired finger because it took a bunch of tapping for me to see mouse get triggered. I was not able to reproduce the 1 second hold result. I'll take a look and see if I can adjust my touch detection to catch this.