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

87
Vistas
Keydown has a delay

I'm using

    document.addEventListener('keydown', function(e) {
  if (e.keyCode == 65) {
    notedo.play()
  }
});

which essentially just plays a sound on keypress, however I'm trying to create sampler and there's a delay pressing a key. Anyway I can get around this? as well as being able to play multiple keys at once?

I am also using this in my HTML side:

<div class="black key" data-note="G#3" onclick="notedo.play()"></div>

So when clicking on my div element above it plays the notedo variable in javascript. I'm trying to find a way to implement key pressing to play the sound as well.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Found my issue which I think was getting confused with delay.

I was actually trying to play the same audio immediately after I press the same button.

I ended up using this!

document.addEventListener('keydown', function(e) {
  if (e.keyCode == 65) {
    notedo.play()
  }
  if (e.keyCode == 65) {
    notedo.play();
    notedo.currentTime = 0
  }
});
about 4 years ago · Juan Pablo Isaza Denunciar
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