+ 6

Mousedown event fires on mobile?

So, while making a game, I stumbled upon a bug where a single click would register twice in the game. Was wondering what the issue could be, and after a while I realized that the handelrs for both mousedwon and touchstart where both being fired. This happened only on mobile Was certain it was an issue with my phone, but then I checked it out with chrome dev tools on my laptop and when inspecting as a mobile device, the same thing happened Yeah, this Is a simple issue to take care of I guess But, does this happen though?

28th Mar 2021, 2:34 AM
Vachila64☕
Vachila64☕ - avatar
12 Answers
+ 4
Russ Hmm, so it seems to be an Android only thing Kode Krasher Here we go again...😎👍
28th Mar 2021, 9:55 PM
Vachila64☕
Vachila64☕ - avatar
+ 4
Russ Yup, seems like an "only Android" issue, smh Your feedback is very much appreciated! ^_^
28th Mar 2021, 10:03 PM
Vachila64☕
Vachila64☕ - avatar
+ 4
Vachila64☕ i added both events and just one was fired. Android OS (6 - 10)
29th Mar 2021, 5:53 AM
Mirielle
Mirielle - avatar
+ 4
The reference link is an article that COMBINES multiple event functions into a SINGLE api. I've never in my life seen or heard of where a mousedown and a touchstart will be fired simultaneously. It just cant happen.
30th Mar 2021, 12:00 AM
Mirielle
Mirielle - avatar
+ 4
Btw i'll now be unfollowing this thread
30th Mar 2021, 12:02 AM
Mirielle
Mirielle - avatar
+ 3
If two events "mousedown" and "touchstart" exist on a code, i've never heard or seen where both will trigger for a device that supports either of the two. However, when a mousedown event has the window's target, the default behavior would be same as the global "click" event except when you explicitly prevent default by calling the function. event.preventDefault(); Your game caling a function twice probably is from another bug(hidden) untill you share it on here, i dont think two similar pointers event (mousedown, touchstart) can be triggered at once
28th Mar 2021, 9:57 AM
Mirielle
Mirielle - avatar
+ 3
Mirielle[ Exams ] I believed the same as well, but from the way to code in the game is, It is certain that the touch and mouse events fire on after another... Are you on android? If so, could you check the code above and check if they both fire for you as well?
28th Mar 2021, 9:57 PM
Vachila64☕
Vachila64☕ - avatar
+ 3
Kode Krasher Another useful template from Space Ace himself! Touchscreen laptops will be at a loss though as they will losse the consistent firing of mousemove, but that's is a little price to pay!
28th Mar 2021, 10:14 PM
Vachila64☕
Vachila64☕ - avatar
+ 2
Here is an example code so you can try it out for yourself... https://code.sololearn.com/WmVwAhHHw6PL/?ref=app
28th Mar 2021, 2:36 AM
Vachila64☕
Vachila64☕ - avatar
+ 2
Just to add to your troubles, onmousedown doesn't trigger anything for me in your example code. Only when I change it to ontouchstart do I get the alert box. This is on iPhone.
28th Mar 2021, 8:57 AM
Russ
Russ - avatar
+ 2
Vachila64☕ Now I just get the "touch event" alert.
28th Mar 2021, 9:58 PM
Russ
Russ - avatar
+ 2
How event propagation works. TWO seperate mousedown events are ONE. Even a HUNDRED mousedown event of the same target are ONE. A mousedown and touchstart arent ONE but of the same pointer's type. No WAY both would be fired on the same device while both adapters are active
29th Mar 2021, 10:25 PM
Mirielle
Mirielle - avatar