on_press and on_release not executing if one is placed after another
See original GitHub issueHi, I’m using on_press
and on_release
to store any currently pressed keys. Unfortunately, if on_press
is placed before on_release
, on_release
is not being executed. If I switch places of on_press
with on_release
, then on_press
is not being executed.
Because of it, I’m using hook
as a workaround, in which I’m checking event_type
and calling proper function.
pressed_keys = []
def add_key(key):
pressed_keys.append(key)
return
def remove_key(key):
pressed_keys.remove(key)
return
keyboard.on_press(add_key)
keyboard.on_release(remove_key) #This is not being executed
Also I have one question: Is there a simpler way of checking in on_press_key
if other keys are also currently pressed? modifiers
is always empty.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:12 (3 by maintainers)
Top Results From Across the Web
onPress/onRelease in Android - Stack Overflow
try this: someView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { if (arg1.
Read more >OnRelease not working - Tasharen Entertainment
I have an OnPress function in the same script and it is working just fine. ... Does it not trigger when a held...
Read more >Handle Press And Release Events in SwiftUI - SerialCoder.dev
Learn how to detect and handle press and release events in SwiftUI, and how to create a custom modifier to simplify that task....
Read more >MouseArea QML Type | Qt Quick 6.4.1
When set to false, the mouse area becomes transparent to mouse events. The pressed read-only property indicates whether or not the user is...
Read more >Scripting API: UI.Button.onClick - Unity - Manual
A Button can have multiple listeners. As an example, in the script example below, btn3 can have TaskOnClick added as a second listener...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello,
I was trying to do the same exact thing with
on_press
andon_release
. It looks like the bug was introduced in a recent update (pip version 0.13.1). I downgraded to version 0.11.0 and that got rid of the bug.To install version 0.11.0 I used the command:
pip install keyboard==0.11.0
Hope this helps!
Fixed it by placing the
on_release()
after all theword_listener()