Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Waiting and listening
#1
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():
Reply
#2
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.
Reply
#3
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Waiting for input from serial port, then move on KenHorse 3 1,011 Apr-17-2024, 07:21 AM
Last Post: DeaD_EyE
  pip stops waiting for python walker 6 1,048 Nov-28-2023, 06:55 PM
Last Post: walker
  Waiting for heavy functions question philipbergwerf 14 3,368 Apr-29-2022, 07:31 PM
Last Post: philipbergwerf
  How to create waiting process? samuelbachorik 4 1,971 Sep-02-2021, 05:41 PM
Last Post: bowlofred
  Listening music from url ebolisa 1 1,667 Nov-25-2020, 07:53 AM
Last Post: ebolisa
  waiting for barcode scanner output, while main program continues to run lightframe109 3 4,641 Sep-03-2020, 02:19 PM
Last Post: DeaD_EyE
  waiting to connect Skaperen 9 3,545 Aug-17-2020, 05:58 AM
Last Post: Skaperen
  Launch another python command without waiting for a return. SpongeB0B 13 10,922 Jun-18-2020, 10:45 AM
Last Post: Yoriz
  How can I make this server stop listening for connections to sockets Emekadavid 0 3,433 Jun-03-2020, 02:28 PM
Last Post: Emekadavid
  waiting for many processes in parallel Skaperen 2 1,887 Sep-02-2019, 02:20 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020