Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

162
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda