Was adding to the event keyboard examples and noticed that only the 1st example actually functions and the following examples don't function. see https://p5js.org/reference/#/p5/keyPressed
Hi @hellonearthis
I would like to work on this issue.
@hellonearthis
I want to try to fix this.
Where can I find the code where keyPressed() is implemented?
I have no idea where the code is, i guess the issue is around having to things tapping into the keyboard event. But on the demos, i can stop both demos and then try to start the 2nd demo with no luck.
Having only one example is the current fix but it's no solution.
keyPressed() is defined in here. I would suggest determining whether the problem is limited to the reference page or is it a general bug in the library first before attempting to fix anything.
keyPressed()is defined in here. I would suggest determining whether the problem is limited to the reference page or is it a general bug in the library first before attempting to fix anything.
In keyIsDown() reference page also we have two examples and there the function is working as expected. So maybe there is an issue with the library.
@limzykenneth can you have the look and tell what may be the issue.
I am new here so not much idea with code base still learning. :)
It might be helpful to find which git commit (if any) introduced the bug. git bisect Can be used for this.
@Ajayneethikannan is this same as #3193, I haven't been following the discussion for some time.
@sanketsingh24 Yes it is ! I will make a pull request as soon as my doubts regarding the issue have been cleared.
Thank you for mentioning it !
@outofambit with reference to your comment #3569 , I think that the bug is mostly due to the global downkey variable as in #3193 . For confirmation ,we can check the event listeners registered for keydown event on the chrome developer tools (elements tab) , and there are three event listeners corresponding to three sketches. If we remove any two event listeners , we can see the keyPressed function working in the remaining one sketch without any errors .
So from what I have found out, I think this issue and #3193 can be combined , while #3569 remains separate.
Also a similar function which depends on the downkeys variable , as in keyPressed() is isKeyDown(),
so in those sketches too , we can see the second sketch failing, https://p5js.org/reference/#/p5/keyIsDown
would love to hear your thoughts on these issues ,
Thank you !
@Ajayneethikannan ohhh yes, that all makes sense! thanks for digging into this! 馃挓
I'm going to close this issue in favor of continuing the discussion/work in #3193 since it accurately describes the underlying issue causing the symptoms documented in this issue description. Thanks all!