I am trying to modify a script that currently toggles the value of a variable when a key is pressed and then lifted. Instead of changing the variable value, I would like to adjust the saturation of the screen based on key presses and releases. How can I achieve this transformation? The current script is as follows:
let x = 1;
window.onkeydown = () => {
let x = 2;
};
window.onkeyup = () => {
let x = 1;
}
To change the screen saturation, use the following CSS: filter: saturate(4);
Just to clarify, I want the screen saturation to shift to saturate(4)
when a key is pressed, and return to normal when the key is released instead of altering the variable x from 1 to 2 as it currently does.