Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
mouseHold and mouseDown - different functionalities

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).

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!