Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

228
Vistas
Javascript: How to be the very first receiver of a mouse/key event

I'd like to recognize any mouse input within a website before any other object has a chance of processing it.
Is there a native solution to this?

Why do I need to get it first?
The site uses event.stopPropagation() on some mouse events. I want to see these events before they are propagated

Notes:

  • I case specifically about chromium. There is no need for cross browser support; But I'd like to avoid chromium hacking.
  • window.addEventListener ("mousedown", ...) doesn't work; it would receive events after other elements already stopped their propagation
  • document.body.addEventListener ("mousedown", ...) doesn't work; it would receive events after other elements already stopped their propagation
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can specify useCapture (the third parameter in addEventListener) as true:

window.addEventListener('mousedown', function(){
  console.log("first")
})

window.addEventListener('mousedown', function(){
  console.log("second") //should fire first
}, true)

window.addEventListener('mousedown', function(){
  console.log("third")
})

about 4 years ago · Juan Pablo Isaza Denunciar
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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda