-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Nature of issue?
- Found a bug
Details about the bug:
I have a sketch where I do an action whenever I click a mouse button. I also check to see if there is a key pressed, to perform the opposite action.
The problem is that, the fist time I click the mouse, the keyIsPressed var always has false, even though I am pressing a key. All the other tries during that run work well, except for the first one.
- Web browser and version: Google Chrome Version 71.0.3578.98 (Official Build) (64-bit)
- Operating System: Windows 7 Enterprise, Service Pack 1
- Steps to reproduce this bug:
Execute the following code. If the first time you click the left mouse button while pressing a key, you will see that the keyIsPressed variable contains false, when it should have a value of true.
function setup() {
createCanvas(250, 250);
myText = "";
}
function mousePressed() {
print(keyIsPressed);
if (keyIsPressed)
myText = "a key is pressed!"
else
myText = "NO key pressed."
redraw();
}
function draw() {
noLoop();
background(128);
text(myText, 10, 30);
}
Metadata
Metadata
Assignees
Labels
No labels