locked
What is the difference between MSPointerDown and click event

    Question

  •  document.getElementById("elemID").addEventListener("MSPointerDown",function(){},false);
    
    
    
    document.getElementById("elemID").addEventListener("click",function(){},false);
    
    

    what is the diff. in above two ? And what to use ?
    Monday, June 25, 2012 1:25 PM

Answers

  • Sorry to correct you, Brian, but click is not limited to mouse: it also works for touch and pen/stylus input as well. Generally speaking, MSPointerDowns get translated into click events and the guidance I've heard from the Windows engineering team is that developers should use click unless they actually need to differentiate between the input type, or need to track multiple pointers at once. That, then, is the primary different: click doesn't know about things like multi-touch, so if you put five fingers on a touch screen you'll get five disparate click events. Using MSPointerDown you could track movements and more complex gestures, if you need to. For example, if you're trying to handle pinch/stretch or rotate gestures, click isn't sufficient because you need to start tracking MSPointerMove, MSPointerUp, and so forth.

    What you said is accurate for the mouse* events of JavaScript, e.g. mouseover, mousemove, etc., because those are only fired for the mouse. But click has a special dispensation to be usable across the board.

    .Kraig

    • Marked as answer by Web-Farmer Thursday, June 28, 2012 1:16 PM
    Monday, June 25, 2012 4:13 PM

All replies

  • Main difference: MSPointerDown is a pointer event -- as such, it's sort of a catch-all for mouse, touch, or pen inputs; Click is just a mouse event.

    In general, developers are encouraged to use MSPointerDown and related pointer events to make their apps as robust as possible. That being said, developers can certainly choose to just handle mouse-specific events. It's really up to you.


    Monday, June 25, 2012 2:02 PM
  • Sorry to correct you, Brian, but click is not limited to mouse: it also works for touch and pen/stylus input as well. Generally speaking, MSPointerDowns get translated into click events and the guidance I've heard from the Windows engineering team is that developers should use click unless they actually need to differentiate between the input type, or need to track multiple pointers at once. That, then, is the primary different: click doesn't know about things like multi-touch, so if you put five fingers on a touch screen you'll get five disparate click events. Using MSPointerDown you could track movements and more complex gestures, if you need to. For example, if you're trying to handle pinch/stretch or rotate gestures, click isn't sufficient because you need to start tracking MSPointerMove, MSPointerUp, and so forth.

    What you said is accurate for the mouse* events of JavaScript, e.g. mouseover, mousemove, etc., because those are only fired for the mouse. But click has a special dispensation to be usable across the board.

    .Kraig

    • Marked as answer by Web-Farmer Thursday, June 28, 2012 1:16 PM
    Monday, June 25, 2012 4:13 PM
  • Actually, mousedown, mouseup, mousemove, (except probably mouseover) etc. work with touch (although probably not multi-touch), as well.  
    Monday, August 20, 2012 7:33 PM