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

91
Views
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 answers
Answer question

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 Report
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!