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

207
Visualizações
HTML Form enter press is keydown instead of keyup/keypress, enabling spam

When using <form> tags, it has a built-in behavior for enter key, which runs the submit. They decided to make it using keydown, so it creates spam issues. For example if I had a form for a todo list, and i hold the enter key then it will spam create the same todo-item. I want it to be keyup or keypress instead of keydown, I would still like enter key to submit rather than getting rid of it all together. Using blur() also doesnt work since it doesnt focus on the button in the first place.

<form>
    <label>username
        <input type="text" />
    </label>
    <label>password
        <input type="text" />
    </label>
    <button type="submit">Login</button>
</form>
document.querySelector("form").addEventListener("submit", event => {
    event.preventDefault();
    console.log( "submitted" );
})
about 4 years ago · Juan Pablo Isaza
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