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

156
Views
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 answers
Answer question

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 Report
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!