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

146
Visualizações
How do I get pressing the enter key to stop being treated like a mouse click in javascript?

I have a program where I have several clickable buttons as well as a reason to click enter. Issue is, if I click a handful of the buttons with the mouse and then click the enter key on my keyboard, it does what enter should do and it also acts as though I had clicked the last button that I clicked one more time. I want the clicking to only be done with the mouse and have the enter key not be able to click buttons. How do I do this? code Here is how I am currently making the buttons clickable and getting the input of the keyboard.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

By clicking on the tile button, it gets focus. Hence, subsequent enter triggers the button.

You could "un-focus" the button:

// tile is a reference to the button, as per your question
tile.addEventListener('click', (evt) => {
  // un-focus
  tile.blur();
  // do some stuff
});
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