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

155
Views
I have (if(e.repeat) return) in a function. I press+hold key1. No repeat. I press+hold key2. No repeat. I release key1. key2 repeats

I have a function called on keydown events.

I have if(e.repeat) return at the start of that function to prevent the rest of it running if I hold down a given key down.

So I press and hold key1. No repeat.
I press and hold key2. No repeat.
I release key1. Key2 repeats.

Also: I press and hold key1. No repeat.
I press and hold key2. No repeat.
I press and hold key3. No repeat.
I press and hold keys4 - 10 (because I only have 10 fingers) without releasing any of the keys. No repeats.
I release any of the keys. Key 10 repeats every time I release any other key.

Conversely, if I release key 10 before releasing any of the other keys: no repeat.

What's happening to make the last key that I press+hold to repeat when I release previously held keys and how do I stop it? I'm clearly missing something, but I have no idea what.

document.addEventListener('keydown', pressKey)

function pressKey(e) {
  if (e.repeat) return
  console.log(`press key ${e.key}`)
}

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!