logo
  • 現在做什麼
  • 關於我

Kalan

文章分類

  • 前端
  • 開發筆記
  • 雜談
  • 年度回顧

快速連結

  • 現在做什麼
  • 關於我
  • 聯絡我
  • 職涯思考🔗

關注我

在福岡生活的開發者,分享軟體開發與日本生活的點點滴滴。

© 2025 Kalan Made with ❤️. All rights reserved.

iOS mousedown event triggering issue

Written byKalanKalanOct 22, 2020
Home/Frontend
💡

If you have any questions or feedback, pleasefill out this form

Japanese原文

Table of Contents

  1. Conclusion

This post is translated by ChatGPT and originally written in Mandarin, so there may be some inaccuracies or mistakes.

iOS has issues with the mousedown handler not functioning correctly in certain versions; however, on other devices (like Android, etc.), mousedown works perfectly fine.

The solution is to avoid using the mousedown handler on mobile devices and instead use touchstart. But will this affect the trigger order? In the original click event, blur is triggered first (if it exists), followed by the click event. To bypass this, mousedown was used as a replacement.

Here’s a simple experiment conducted on CodePen:

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

It turns out the trigger order is touchstart > mousedown > blur. It seems that when both touchstart and mousedown events are added, and both are supported, the events occur in the order of touchstart > mousedown.

After doing some research online, I found that the mousedown event is not triggered on iOS versions prior to 13; it works normally on iOS 13 and later. Additionally, for iPads, it appears that you can distinguish whether the touch is coming from a finger or an Apple Pencil.

Conclusion

  • Be cautious when binding mousedown events on iOS; it's best to use touch-related events instead.
  • iOS 13 serves as a dividing line; additional testing is necessary for versions below 13.

I'll document this here for now and will add detailed behaviors later.

← Explanation of regular expression to add a number to comma站在中間的那群人 / 做出選擇的那群人 →

If you found this article helpful, please consider buying me a coffee ☕ It'll make my ordinary day shine ✨

☕Buy me a coffee

Table of Contents

  1. Conclusion