javascripthtmlclickmouseeventpointer-events

Is there a pointer event that equals to 'click' event?


The 'click' event is a mouse event which fires after both the mousedown and mouseup events have fired.

Now pointer event has a broader use case, so I wonder if there is a corresponding 'click' event for pointer event also?

Thanks. Andy


Solution

  • As to the question: Is there a pointer event that's equivalent to the click event?

    The answer is no.

    As to the question: Does a pointer press dispatch a click event?

    Answering that may take some testing.

    Using a little test page that reports every pointer event and click event, I obtained the following events for a single finger press on an iPhone:

    16:01:45.416 - pointerover - width: 48.5, height: 48.5
    16:01:45.417 - pointerenter - width: 48.5, height: 48.5
    16:01:45.418 - pointerdown - width: 48.5, height: 48.5
    16:01:45.601 - pointerup - width: 0.0, height: 0.0
    16:01:45.602 - pointerout - width: 0.0, height: 0.0
    16:01:45.602 - pointerleave - width: 0.0, height: 0.0
    16:01:45.636 - click - width: NaN, height: NaN
    
    

    (the width and height values report the size of the pointer tip, which in this case is a finger)

    So it seems that at least on an iPhone, a click event is dispatched with a finger press.