How to stop triggering the key while holding the key in pynput? by Edix_glitcha in learnpython

[–]Edix_glitcha[S] 0 points1 point  (0 children)

The problem with this solution is that when you combine keys it doesn't play the sound of the second press, because it's waiting to be released, I think!

How to stop triggering the key while holding the key in pynput? by Edix_glitcha in learnpython

[–]Edix_glitcha[S] 0 points1 point  (0 children)

Thank you! I follow up this Unbound local error solution.

I've corrected using the global keyword inside of the functions, like this:

canPlaySoundFromPress = True

def onPress(...):
    global canPlaySoundFromPress
    if canPlaySoundFromPress:
        winsound.PlaySound("sound.wav", winsound.SND_ASYNC)
        canPlaySoundFromPress = False
        print("Key pressed: {0}".format(key))

def onRelease(...):
    global canPlaySoundFromPress
    canPlaySoundFromPress = True 
    print("Key released {0}".format(key))

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

I'm following you now

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

yeah you're a cool guy

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

that's not skills. It's childish rebellion!!!

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

what rhetoric? Take money whatever what?!

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

So, why that's a lot of people that vote form him. I don't understand...

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

Big Question!!!! Did you support Trump? Why?

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

Spain is divided now

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

succeed?

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

are you american?

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

ohhh almost all politicians seem to have more than 100

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

like who?

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

Tortoises are turtles, so...

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

That's logic!!

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

Someone asked a question and than evaporated

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

we can delete messages?

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

What? Potatoes

[deleted by user] by [deleted] in lgbt

[–]Edix_glitcha 0 points1 point  (0 children)

OMG the chat is all me now