I've got a sketch where I want to be able to "chord" keypresses - you hold down one key, then another, and both key presses can be detected.
Here's the code...
void keyPressed() {
if (key=='p') lambda0+=.025;
if (key=='o') lambda0-=.025;
if (key=='q') theta1+=.025;
if (key=='a') theta1-=.025;
if (key==' ') {
lambda0=0;
theta1=0;
}
}
If I hold down 'p', the value of key is 'p' - until I press 'a', then it's 'a' all the way. I want to be able to trigger lines 2 and 5 if the user holds down the keys 'p' and 'a' at the same time.
Is there any way to detect when the user has held down multiple keys?