mousePressed/mouseReleased broken on mobile devices

So yesterday I created this Puzzle Game, which is based on another game I found based on lights out. It worked very well and I had fun playing around with it. Today I tested it out on a mobile device. I discovered how broken mousePressed was. I also discovered that mouseReleased was broken too. I met this problem developing Bullet Hazards 2. I brushed it off as that wasn’t that game breaking and it may have just been something wrong with my code. After all the total lines of code is nearly thrice as long as any other game I’ve created. This time I realized it definitely wasn’t my fault. I discovered mousePressed and mouseReleased from the p5 examples and to my surprise they did work in gameLab. You may be wondering why I don’t use mouseWentDown or mouseWentUp. Those are based on frame rate, which makes it inconsistent as sometimes when you click on a button, the game doesn’t acknowledge it. I came up with an extremely dirty solution to solve the problem, to add a debounce of 200 milliseconds (a fifth of a second) on clicking the same tile twice. Now I wish I could provide a video of the problem happening but unfortunately I couldn’t. The image below shows the edit I had to make to the game to solve the problem.

This may happen because mousePressed and mouseReleased isn’t really something supports. That may be the reason nobody has noticed this bug and fixed it. I don’t know about mouseWentDown and that such but I’m sure it works perfectly fine. However the 2 functions along with keyPressed and keyReleased are very useful for a game that may lag very heavily. Another way I may be able to solve this is if there was a way to detect whether the device is a computer or a phone.

My point is that there needs to be a fix to mousePressed and mouseReleased on mobile devices so that it wouldn’t double click whenever I tap on it. mousePressed and mouseReleased is important because they ignore frameRate and work even if the game is running ridiculously slow (which happens a lot). mouseWentDown and mouseWentUp is not a direct replacement to mousePressed and mouseReleased because they can break when the frameRate is too low.