Is there a way to detect continual mousedown? In other words, I want a function to continue to run while the left mouse button is being pressed. Here is an example of what im trying to do. I have a button that controls the scrollLeft position. It increments by 20 on every click, but I want it to continue incrementation while the mouse button is left pressed and stop onmouseup.
Similar to how the arrows on a scroll bar work when you leave the mouse button pressed
    var wrapperDiv = $("#wrapper-div");
    var scrollWidth = 0;
    $("#right-button").click(function() {
      if(scrollWidth < wrapperDiv[0].scrollWidth) {
        scrollWidth = scrollWidth+20;
        wrapperDiv.scrollLeft(scrollWidth);
      }
});
 
     
     
     
    