-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Repeated key presses when a modifier key is held do not fire events #7282
Comments
Hi @davepagurek, I’m interested in working on this issue but I'm having difficulty reproducing it. |
Sure thing! I'll try to explain the logs in the console and what's expected. In this sketch: https://editor.p5js.org/davepagurek/sketches/BQ2Lmicii If I click on the canvas to give it focus, and then do the following:
I would expect the "undo" log to happen once per z press, for a total of five times. Instead it only happens once. I see the "down" log (logged when a key is depressed) just twice, once for the first press of the meta key and once for the first press of the z key, and not repeatedly after each z press like i would expect. |
Hello @davepagurek, I reviewed the code and confirmed that the issue stems from the event not firing multiple times. This problem can be resolved by commenting out the following section in the if (this._downKeys[e.which]) {
// prevent multiple firings
return;
} You can find the relevant code here. By removing this block of code, I am confident that the issue will be resolved. However, I am uncertain if this change might introduce additional issues elsewhere in the codebase. |
I suspect it was introduced so that There are other ways once can have that same behaviour, such as returning if the I was doing some more research into why this event isn't being fired in the first place by the browser, since fixing that would be the ideal scenario. It sounds like it's just how Chrome and Safari work on Mac and that there may not be much we can do about it. So, knowing this behaviour, it looks like maybe the best way forward is to:
Here's a quick mockup of that: https://editor.p5js.org/davepagurek/sketches/OeM8Bp42E How do you feel about this workaround? It means that while you press and hold meta, and then tap and release z, while you continue to hold meta, p5 will log that |
I see the approach you're taking: You're adding a check for the Meta key combinations.
|
I think this solution solves the issue of repeated keypresses with meta key, the manual tracking of "_metaKeys" seems like a solid approach to me |
i want to contribute on this issue.please assign me |
Thanks @thejon07, feel free to open a PR implementing what was discussed above! Most p5 development is off of the |
Can i work on this ?? |
@davepagurek I think for 2.0 its not quite ready yet as I still want to go through one more look into core refactor and we might want to fix the tests we ignored plus converted them to import individual modules first. |
Ok sounds good, @thejon07 feel free to just work off of @JagjeevanAK, @thejon07 has just volunteered, so we'll let them work on this one first. |
how can i start development server |
You can also run |
Unfortunately my laptop was stolen, so I’ll need some time before I can contribute further, as I don’t currently have a laptop. |
is this issue till open |
@msudipta888 This issue is currently already assigned so we are not looking for someone else to work on it at the moment. Thanks. |
My mac was stolen, so I currently don't have mac OS. Can I use Windows to address this issue instead? |
We've had contributors work on Windows in the past! Let us know if you run into issues. |
I'd like to contribute to this issue please let me know |
When pressing and holding cmd + z, browsers fire repeated keydown events for the z key. the goal is to ensure the event is triggered only once per keypress. Is my understanding correct? |
Hi @davepagurek I have created a pull request which resolves this issue please check! |
@thejon07 I think so. at least that's the current behaviour, so we can maintain that for now. |
Hi @thejon07, apologies for having this issue be resolved by another PR. For future contributors who may not know, our contributor guidelines say:
We generally try to abide by that, so I'm sorry your spot in the queue got jumped in this instance. If you're still interested in contributing, let me know if any of the other issues we've tagged as Help Wanted are of interest! |
That's okay,i understand.i'd still love to contribute.Let me take a look at the other help wanted issues and see where i can assist. |
Most appropriate sub-area of p5.js?
p5.js version
1.10.0
Web browser and version
Firefox, Chrome
Operating system
MacOS
Steps to reproduce this
The goal here was to have a custom undo handler using the meta key. A single meta-z should be handled, but also holding the meta key and repeatedly hitting the z key should also fire. On my mac, I'm finding that this works for the first press but not repeated presses:
Meanwhile, doing it with vanilla js does work:
Narrowing it down, it looks like the key up event isn't firing after the first meta-z if I release the z but hold the meta key. I'm not sure yet why that is, but because of that,
this._downkeys
isn't getting reset to false, so I suspect the second event isn't getting fired because of this condition:p5.js/src/events/keyboard.js
Lines 443 to 447 in e9ee594
The text was updated successfully, but these errors were encountered: