· 2 min read

Issues with mousedown Event Triggering on iOS

This article was auto-translated from Chinese. Some nuances may be lost in translation.

In certain versions of iOS, mousedown handlers do not work properly, although on other devices (like Android, etc.), mousedown still works as expected.

The workaround is to avoid using mousedown handlers on mobile devices and use touchstart instead. However, will the execution order be affected? Originally, in a click event flow, blur triggers first (if applicable) before the click event fires; mousedown was used specifically to circumvent this.

A simple experiment on CodePen:

See the Pen touchstart-test by 愷開 (@kjj6198) on CodePen.

We can see that the trigger order is touchstart > mousedown > blur. It seems that when both touchstart and mousedown events are bound, and both are supported, they will fire in the order of touchstart > mousedown?

After looking it up online, I found that the mousedown event only fails to fire on iOS < 13; it works normally starting from iOS 13. Additionally, on iPads, it seems possible to distinguish whether a touch comes from a finger or an Apple Pencil.

Conclusion

  • Be cautious when binding events like mousedown on iOS; prefer touch-based events where possible.
  • iOS 13 and iOS < 13 mark a dividing line, so separate testing is necessary.

Recording this here for now, and I’ll follow up later with more detailed behaviors.

Related Posts

Explore Other Topics