The Relationship Between keyPressed() and draw()
in
Programming Questions
•
2 years ago
FYI, I'm assuming that this is standard behavior - keyPressed() only works if the draw() function is present.
For example, the following works, but remove draw() and keyPressed() dies.
So how do I get keyPressed() functionality when draw() is not present?
Best Regards, Jim
For example, the following works, but remove draw() and keyPressed() dies.
- int value = 0;
- void draw(){}
- void drawit() {
- fill(value);
- rect(25, 25, 50, 50);
- }
- void keyPressed() {
- if (value == 0) {
- value = 255;
- } else {
- value = 0;
- }
- drawit();
- }
So how do I get keyPressed() functionality when draw() is not present?
Best Regards, Jim
1