Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!