I am trying to have a functionality (1) if mouseDown has been pressed for more than x amount of time. If it has been briefly pressed (less than x amount of time) i want to have another functionality (2) happen.
function onMouseDown(event) {
var delay;
timeClickDown = Date.now();
delay= timeClickDown-timeClickUp;
if(delay>x) {functionality(1)}
else if(delay<=x) {functionality(2)}}
function onMouseUp(event){
timeClickUp = Date.now();
}
Doing this right now works but only after i click twice (because timeClickDown gets its value only after first click).