Python Forum

Full Version: Waiting and listening
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!
I have been writing a program which listens for any keyboard input by the user. If specific combinations are input, certain tasks are performed, which need to happen as soon as the combinations are pressed. However, if no keyboard input is present for a period of time (say 10 seconds), the program will prompt the user to resume the activity.

I have tried this:
def waiter():
What you show could never be run by itself.
Are you using a package like: https://pypi.org/project/keyboard-listener/ ?
Please show all code.
First priority has to be familiarizing yourself with some library that can handle keyboard events. I'm sure there are many, I use pygame, but there is another module called "Keyboard" that should do fine.

https://www.geeksforgeeks.org/keyboard-m...in-python/

Step one to find and figure out how to capture the input you want. HINT: this is in a loop.

Step two save those inputs to a list.

Step three, write code that checks that list for the combinations you are looking for.

Maybe write a program (and post it here) that just prints the key you press when you press it. From there it is easy to help with the next step.