• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

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

almost 3 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda