boppreh / keyboard

Hook and simulate global keyboard events on Windows and Linux.
MIT License
3.76k stars 433 forks source link

Question: is there any way to get if any non specified key was pressed without blocking #578

Open garandal245 opened 1 year ago

garandal245 commented 1 year ago

pretty much i just need to check if any key on the keyboard without having to specify a key to check is pressed without blocking program from continuing if there is none

while True:
    if keyboard.read_event("any key") == True):
        print("doing thing 1")
    else:
        print("doing thing 2")

and idk if im crazy but i cant seem to find anything that does that in the documentation

melomane63 commented 7 months ago
 while True:
      event = keyboard.read_event()
      if event.event_type == keyboard.KEY_DOWN:
                       print("doing thing 1")
       else:
               print("doing thing 2")