touchEnded() clicks twice

Hi everyone,
I am having some problem with touchEnded() function.
I am using it to switch from a case to another and it works fine with the mouse on laptop.
However, if I use a tablet it seems that the touch lasts longer as there was a lag between the touch and the end of the touch. Or it’s like the touch happened twice.

For example if I click in (xpos, ypos) and I am in case1, when it switches on case2 the touch is still active in the same position and it messes up with the things happening in the second case.

I am trying to understand what could be wrong but I can’t. The mouse click works well, the touch doesn’t.

here is a short version of the code. I have already tried to avoid the first conditional (mouseButton===LEFT) but the problems is still there.

Any idea anyone on what may be going on?


if(mouseButton === LEFT){

			case 'one':

				//code here
				pages = 'two';


			case 'two':
				//code here
				pages = 'three';

1 Like

Check these next links as they can provide some suggestions that could help in your current isssue:

Where are you calling this function from? It is better to provide a minimum version of your code demonstrating your problem.


1 Like

Hi, thanks for replying. I’ve read your links and I started exploring from there.
Apparently the problem is in the browser that I use.
Chrome should read both mouse and touch and give priority to whatever device is used but Firefox or other browsers don’t. However, I couldn’t find a way to fix it even following the examples provided.
At the moment I am thinking to avoid touch devices because I don’t have much time but I would like to get back to it later.

I will post some code that makes sense as soon as I can :slight_smile: