-
Notifications
You must be signed in to change notification settings - Fork 4
Catch auto-repeat keys in pyside6 #93
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
Interesting, we've not accounted for auto-repeat yet. (still the pygfx fly controller works well enough). I see that glfw and wx also have auto-repeat (did not try jupyter yet). Some options:
I think the first option would make the most sense. @Korijn thoughts? |
I would suggest to copy existing standards if there are any, like option 1. |
@SpicyRicecaker would you be up for a pr? |
I'll look into it in the next few days! |
Ok web
I think this option of having a |
Mmm, in jupyter_rfb the repeated events are actively suppressed. Proposal: key_down and key_up events don't emit in repeat mode, but the 'char' event does. I think that makes sense, because when listening to key down and up events you are usually doing some sort of interaction. While the repeated events are useful when inserting/deleting text. |
Yes I was just looking into that too when trying to get consistent behavior on the jupyter_rfb backend! if (!e.repeat) { that.send(event); } // dont do the sticky key thing I now also think it would make sense for those repeating events to be filtered out by default by the qt, glfw, and wx backends. I can't really think of a use case for having the key_down and key_up events firing in addition to the char events. By filtering repeat events by default, we still keep the functionality the same thanks to repeating char events. The only thing would be maybe arrow keys and function keys would no longer be able to be repeated, but that's probably not a huge concern. Considering pygfx is pretty high level too, just having users not having to deal with this at all by default would also reduce friction in using the library. |
I made some updates to jupyter_rfb while looking into this: vispy/jupyter_rfb#119
Yes, good point! I think they should be emitted as (repeatable) 'char' events. Same for backspace and del, and maybe a few others. But let's leave that for another day ... I consider the 'char' event very much experimental for now. |
Is it possible to block auto-repeat key events in
pygfx
for a qt window?Background
On Linux, in both X11 & Wayland, whenever I press and hold a key, a key release event is fired on key repeat. Here is a minimal example of
pyside6
demonstrating this behavior on linux:output (after pressing and holding, but not physically releasing the 'A' key):
This makes it really hard to implement a fly camera manually, since it's really hard to tell when the player has let go of the forward button.
After a lot of gpt and trial and error, I narrowed it down to every single qt window on linux having this problem. But
pyside6
has this nice function calledPySide6.QtGui.QKeyEvent.isAutoRepeat()
that automagically detects this key repeat behavior and filters it out.Utilizing this, I've edited the above code to check for auto-repeating events before printing them, and the result is as follows:
The code when run, has the following output, after clicking, holding (for a few seconds), and then releasing the 'A' key:
This is a functionality that I need in
pygfx
, is there currently a way to do this?The text was updated successfully, but these errors were encountered: