Touch controls, is there a way to determine when touch move stopped?

So I have been trying to wrap my mind around touch controls.

For example, let’s say I place my finger on the screen and then move it to the right, it should know I’m moving to the right, and then from there if I move my finger to the left it should know that too, but the part I’m not sure how to determine is when my finger just stops and doesn’t move. Not sure how to get a function in that situation.

I got it to know when I’m moving right to left, but perhaps my way of doing it isn’t smart. And not sure how to fire off something to know when it’s stopped.

Here’s the code.

PlayerControls.prototype.onTouchMove = function(event){
    var touch0 = event.touches[0].x;
    if(this.touchX != touch0){
        if(this.touchX > touch0){
            this.touchX = touch0;
        } else if(this.touchX < touch0){
            this.touchX = touch0;

Are you trying to do a virtual joystick?

perhaps technically, but not directly.

Essentially if I have my phone and I press and move right or left it should move right to left and if I don’t move my finger nothing should happen.

I’ve been using the touchmove for it all.

Unfortunately, there is no such touch event that would be constantly performed when you hold your finger on the screen without moving it. However, you can implement your own logic for this event. To do this, you need an update method that provides a playсanvas, a counter that will record the finger hold time and the value of the time interval, which is needed to run your code. I quickly assembled the scene here:

Also, this script that implements touch-based virtual sticks might be interesting to you:

(Line 229)