-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[p5.js 2.0 Bug Report]: misleading keyIsDown() documentation #7786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you! |
I believe this error is arising due to the fact that event handling has changed in 2.x |
That's correct @mudit06mah , it's a breaking change which happend on this PR: #7472 Now, you can't use any code inside Thanks @MrDuckyTesla for catching this, it's another breaking change. Solution: We should fix the docs and remove the usage of code at description where it says it will work using code as well. If anyone is interested in fixing this up, I am happy to assign to them. Thanks everyone for their inputs. 🙂 |
Also, if possible @MrDuckyTesla can you please update the heading of this issue so it would be easy for everyone to know what's getting fixed? Maybe it's an error in the docs, so we could write the same as heading? |
@perminder-17 I hope that this title is more accurate regarding the issue. |
Yes, this looks great. |
The reason you're seeing false rapidly in the console is because the draw() function in p5.js runs about 60 times per second. Inside it, you're calling: console.log(keyIsDown(88)); 💡 Suggested Fix (to reduce console spam): Only log when the key is actually pressed: if (keyIsDown(88)) { Hope this helps! |
Hi, thanks for the suggestons. I think it could be one of the reasons but only in 1.x versions of p5.js. If you do anything like // this works with 1.x versions. in 2.x version it will console nothing.
if (keyIsDown(88)) {
console.log("X is being held down");
} in 2.x version, you could still see nothing in the console but if you do: if (keyIsDown('x')) { // replace with x
console.log("X is being held down");
} You could probably see it logs in the console. |
It seems the main task is to update the JSDoc for @perminder-17 Could you please assign this to me? |
Yes, correct. I have assigned this to you🙂 |
Most appropriate sub-area of p5.js?
p5.js version
2.0.1
Web browser and version
Google Chrome Version 23H2 (Build 22631.4460)
Operating system
Windows 11
Steps to reproduce this
Steps:
Snippet:
The text was updated successfully, but these errors were encountered: