I want to create a code where when I click a key on the keyboard it will play music and draw a rectangle. I have managed to add music using the keyTyped() function but I am not sure how to add a rectangle to the canvas.
How to use the draw and keyTyped() function at the same time?
Something like this:
function setup() {
createCanvas(400, 400);
background("white");
}
function keyTyped(){
//play sound
fill("black");
rect(50, 50, 100, 100);
}