Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda