Detecting Tap vs Drag

I am having trouble getting this code to detect when the user just did a quick tap, rather than dragging their finger around. I have tried a few methods, but it’s either ignoring the quick tap or doing both actions.

What am I missing?

void Update()
{
    if (Input.touchCount > 0)
    {
        theTouch = Input.GetTouch(0);

        if (theTouch.phase == TouchPhase.Began || theTouch.phase == TouchPhase.Moved)
        {
            curPosition = theTouch.position;
            Vector3 travel = curPosition - oldPosition;

            cursor.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(curPosition.x, curPosition.y, 10.0f));

            // This needs to decide if it's a tap or a squiggle.
            if (travel.magnitude > 4)
            {
                // Add the coordinate point to the squiggle collection.
                squiggle.points2.Add(curPosition);
            }
            else
            {
                // Here is my problem
                // spawn a prefab
            }

            oldPosition = curPosition;
        }


        if (theTouch.phase == TouchPhase.Ended)
        {
            // Do the stuff we want after the finger has lifted
        }
    }
}

I won’t write any code but I will explain how you can do it.

Drag comes before the tap. Tap is only executed when the finger is up.

But before that, you have to create a time threshold variable that checks if 0.1f has passed. Then if it’s larger than 0.1f, then it’s a drag, if it’s less than that, then it’s a tap.

So in theory, the tap is only executed if the user held his finger less than 0.01f seconds on the screen.