You can check if you press and move the mouse. The mousePressed method will only return true once when the mouse changes from not-pressed to pressed. mouseDragged will return true until the mouse is not pressed anymore.
mouseDragged will return true until the mouse is not pressed anymore.
mouseDragged only returns true when the mouse is moved with a mouse button in the down position. It does not return true if movement has stopped while a button is down.