mirror of
https://github.com/processing/processing4.git
synced 2026-02-10 09:09:26 +01:00
keep track of number of keys pressed so that keyPressed works with multiple keys (fixes #4993)
This commit is contained in:
@@ -658,6 +658,7 @@ public class PApplet implements PConstants {
|
||||
* @see PApplet#keyReleased()
|
||||
*/
|
||||
public boolean keyPressed;
|
||||
int keyPressedCount;
|
||||
|
||||
/**
|
||||
* The last KeyEvent object passed into a mouse function.
|
||||
@@ -2934,11 +2935,13 @@ public class PApplet implements PConstants {
|
||||
|
||||
switch (event.getAction()) {
|
||||
case KeyEvent.PRESS:
|
||||
keyPressedCount++;
|
||||
keyPressed = true;
|
||||
keyPressed(keyEvent);
|
||||
break;
|
||||
case KeyEvent.RELEASE:
|
||||
keyPressed = false;
|
||||
keyPressedCount--;
|
||||
keyPressed = (keyPressedCount == 0);
|
||||
keyReleased(keyEvent);
|
||||
break;
|
||||
case KeyEvent.TYPE:
|
||||
|
||||
Reference in New Issue
Block a user