keep track of number of keys pressed so that keyPressed works with multiple keys (fixes #4993)

This commit is contained in:
Ben Fry
2017-04-24 20:14:44 -04:00
parent 1c44727856
commit fc0d36e07c
2 changed files with 6 additions and 1 deletions

View File

@@ -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:

View File

@@ -1,6 +1,8 @@
0259 (3.3.2)
X add (far) more efficient file loading for loadBytes(File)
X add loadBytes(URL) variant that uses content length header for array size
X keyPressed is false if one key is released while multiple keys are pressed
X https://github.com/processing/processing/issues/4993
andres
X Assigning Pixels Vertically Flipped in P2D