I have an image that I am rendering, using loadImage. How can I make it so when I press h on my keyboard, will hide the image? And how can I fade out the image?
Code:
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Image Testing</title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.min.js"></script>
<script src="script.js"></script>
</body>
</html>
script.js
let img;
function preload() {
img = loadImage('https://images.pexels.com/photos/20787/pexels-photo.jpg?auto=compress&cs=tinysrgb&dpr=1&w=500')
}
function setup() {
createCanvas(500, 300);
}
function draw() {
background(225);
fill(0);
image(img, 0,0)
}