This is what I came up with on the spot.
void keyReleased() {
if (keyPressed && ((key == 'a' || key == 'A')) {
flagC1 =true
}
}
void draw() {
if (keyPressed) {
if (key == 'a' || key == 'A') {
background(255,0,0);
}
}
image(imgC1,350,350,300,50);
}
this is the rest of the code if you need it
PImage imgA,imgB,imgL; //images for beginning screens
PImage imgQ1,imgQ2,imgQ3,imgQ4; //images for the questions
PImage imgC1,imgC2,imgC3,imgC4; //answers for question 1
boolean flagA=true;
boolean flagB=true;
boolean flagL=false;
boolean flagQ1=false;
boolean flagC1=false;
void setup() {
size(1000,1000);
background(100,255,210); //background color
imgA = loadImage("https://www.openprocessing.org/sketch/813047/files/Screenshot%202020-01-08%20at%209.48.03%20AM.png"); //img link
imgB = loadImage("https://www.openprocessing.org/sketch/813047/files/Screenshot%202020-01-08%20at%209.44.31%20AM.png");
imgL = loadImage("https://www.openprocessing.org/sketch/813047/files/Screenshot%202020-01-09%20at%2010.10.31%20AM.png");
imgQ1 = loadImage("https://www.openprocessing.org/sketch/813047/files/Screenshot%202020-01-16%20at%208.50.12%20AM.png");
imgC1 = loadImage("https://www.openprocessing.org/sketch/813047/files/Screenshot%202020-01-16%20at%209.50.02%20AM.png");
noStroke();
}
void draw() {
if (mousePressed && (mouseButton == LEFT)) {
background(225,0,0);
noLoop();
}
else if (mousePressed && (mouseButton == RIGHT)) {
background(0,225,0);
noLoop();
}
if (flagA)
image(imgA, 500, 530, 100, 50);
if (flagB)
image(imgB, 400, 400, 400, 50);
if (flagL)
image(imgL,400,430,200,150);
if (flagQ1)
image(imgQ1,300,300,400,80);
if (flagC1)
image(imgC1,350,350,300,50);
}
void mousePressed() {
if (mouseButton == LEFT) {
flagA=false;
flagB=false;
flagL=true;
flagQ1=false;
}
if (mouseButton == RIGHT) {
flagA=false;
flagB=false;
flagL=false;
flagQ1=true;
}
}
Thanks in advace for the help.