Detect Hold Mouse-Click in Javascript
<p>Here is my code:</p>

<pre><code>var mouseDown = false;

document.body.onmousedown = function() { 
  console.log("MOUSE DOWN");
  mouseDown = true;
  increaseRad();
}
document.body.onmouseup = function() {
  console.log("MOUSE UP");
  mouseDown = false;
}

function increaseRad(){
  rad = 0;
  while(mouseDown){
    console.log("mouse is still down");
    rad++;
    console.log(rad)
  }
}
</code></pre>

<p>When I press down, <code>increaseRad</code> is run, but the while loop inside never ends.</p>

<p>Any idea why?</p>