Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

232
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda