Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

90
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda