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

145
Views
Toggle the ability to use spacebar when enter is pressed

Currently I am trying to make it so whenever you click enter, it toggles the ability to use the spacebar. It will by default be set to let you not use the spacebar but when the enter key is hit, that is toggled and you can use it. when you click it again you are unable to use it again.

let toggleee = "false"

document.addEventListener("keypress", function(event) {
  if (event.keyCode == 13) {
if (toggleee = "false") {
    let toggleee = "true"
} else if (toggleee = "true") {
    let toggleee = "false"
}
  }
});

document.addEventListener("keypress", function(event) {
  if (event.keyCode == 13) {
      setTimeout(function() {
    // code to execute after delay
    if (toggleee = "false") {
    window.onkeydown = function(e) {
return !(e.keyCode == 32);
}
} else if (toggleee = "true") {
    return;
}
  }, 500);

  }
})

Instead of doing what its intended to do, it ends up making it so spacebar works once and then when you do the toggle it just never works again. Please help it would be greatly appreciated.

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!