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
  pip stops waiting for python walker 6 970 Nov-28-2023, 06:55 PM
Last Post: walker
  Waiting for input from serial port, then move on KenHorse 2 834 Oct-17-2023, 01:14 AM
Last Post: KenHorse
  Waiting for heavy functions question philipbergwerf 14 3,278 Apr-29-2022, 07:31 PM
Last Post: philipbergwerf
  How to create waiting process? samuelbachorik 4 1,930 Sep-02-2021, 05:41 PM
Last Post: bowlofred
  Listening music from url ebolisa 1 1,636 Nov-25-2020, 07:53 AM
Last Post: ebolisa
  waiting for barcode scanner output, while main program continues to run lightframe109 3 4,585 Sep-03-2020, 02:19 PM
Last Post: DeaD_EyE
  waiting to connect Skaperen 9 3,468 Aug-17-2020, 05:58 AM
Last Post: Skaperen
  Launch another python command without waiting for a return. SpongeB0B 13 10,692 Jun-18-2020, 10:45 AM
Last Post: Yoriz
  How can I make this server stop listening for connections to sockets Emekadavid 0 3,386 Jun-03-2020, 02:28 PM
Last Post: Emekadavid
  waiting for many processes in parallel Skaperen 2 1,858 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