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

157
Vistas
Input text stacking

I'm making a clicker game in which you press spacebar to increase the counter. Every time the counter goes up the next value is "stacked" on top of it, making it overlap. So if the counter was 1 and the spacebar is pressed, then the next value,(2) would overlap the 1. How do I fix this? (Please bear in mind that I'm not very well versed in coding yet, so please try to keep it as dumb as possible)

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

0

You can try something like the following:

var count = 0;
document.addEventListener("keypress", function(e) {
    if (e.code === "Space") {
        count++;
        document.getElementById("counter").innerHTML = count;
    }
});
<div>Count: <span id="counter">0</span></div>

This will replace the previous value with the new counter value everytime the space bar is pressed

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