use keypressed p5.js even if the key is not pressed code example
Example: how to register key presses in p5.js
function keyPressed() {
if (keyCode === LEFT_ARROW) {
value = 255;
}
function keyPressed() {
if (keyCode === LEFT_ARROW) {
value = 255;
}