mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 05:39:18 +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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user