3
respostas

Já escrevi umas 3x e não consigo fazer funcionar

Eu tento sempre escrever em inglês e já mudei várias vezes e não consigo fazer funcionar:

const keyList = document.querySelectorAll('input[type=button]');

for(let ind = 0; ind < keyList.length; ind++) {
  const key = keyList[ind];

  key.onkeydown = function(evento) {
    if (evento.code === "Enter" || evento.code === "Space" {
        key.classList.add('ativa');
        };
}
  key.onkeyup = function() {
    key.classList.remove('ativa');
  };
};
3 respostas

const keyList = document.querySelectorAll('input[type=button]');

for(let ind = 0; ind < keyList.length; ind++) { const key = keyList[ind];

key.onkeydown = function(evento) { if (evento.code === "Enter" || evento.code === "Space") { key.classList.add('ativa'); }; } key.onkeyup = function() { key.classList.remove('ativa'); }; };

a unica falha que eu achei foi que voce nao fechou o if faltou om parentese final na função

espero ter ajudado.

obrigado pela ajuda nos parênteses! consertei, mas mesmo assim segue sem funcionar :/

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software