var mdflag;
var count = 0;
document.addEventListener("mousedown",mdown,false);
    document.addEventListener("mouseup",mup,false);
}
function mdown()
{
    mdflag=true;
    while(mdflag)
    document.getElementById("testdiv").innerHTML = count++;
}
function mup()
{
    mdflag = false;
}
I'm wanting to run code while the mouse is down, i cant find anything to suggest i can do while(mousedown) so i've tryed making a flag for mousedown which is reset on mouse up however i beleive the while loop is whats causing me to go get stuck in an infinite loop.
Any advice to help with what i'm trying to acheive?