How to limit key press to one time and not repeat when help down
in
Programming Questions
•
5 months ago
having trouble with making it so when i hit a button it only makes one rectangle instead of a few. anyone know how to limit it?
thanks here is the code:
void setup() {
size(2000,1000);
background(250);
}
void draw() {
float r = random(0,2000);
float a = random(0,250);
float b = random(0,250);
float c = random(0,250);
if (keyPressed) {
if (key == 'a' || key == 'A') {
fill(a , b, c);
rect(r, 700, 50, 50); }
if (keyPressed) {
if (key == 'b' || key == 'b') {
fill( a , b ,c);
rect(r, 700, 50, 50); }
}
if (keyPressed) {
if (key == 'c' || key == 'c') {
fill( a , b ,c);
rect(r, 700, 50, 50); }
}
if (keyPressed) {
if (key == 'd' || key == 'D') {
fill( a , b ,c);
rect(r, 700, 50, 50); }
}
}
}
1