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

94
Visualizações
JavaScript toggle saturation onKeyDown

I have a script that toggles the value of a variable when a key is pressed and the key is lifted. I'm wondering how I can change this so that instead of changing a variable value when a key is pressed, the saturation on the screen will change and when the key is lifted, the saturation will revert to its original value. How can this be done? The script:

 let x = 1;
window.onkeydown = () => {
let x = 2;
};

window.onkeyup = () => {
 let x = 1;
}

css to change the screen saturation: filter: saturate(4);

Just to clarify, when the keydown function occurs instead of changing the variable x from 1 to 2, the screen saturation should change to filter: saturate(4); and when the key is lifted, the screen saturation should revert to normal.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can do almost anything you want in those functions:

window.onkeydown = () => document.body.style.filter = "saturate(4)";
window.onkeyup = () => document.body.style.filter = "";
about 4 years ago · Juan Pablo Isaza Relatório
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