Python keyboard

I quote the wait method of the keyboard module to report an error

clipboard.png

Aug.28,2021

Hello, I just went to see the source code. You used this keyboard.wait () incorrectly. Wait () this method does not press the hotkey of the keyboard, then the, wait () is always blocked. So you can't just print keyboard.wait (). You write that function above to bring out the wait () print that has been blocking, because wait () has been blocking all the time, and when you print, you actually execute the statement after the print (wait () method else), so it will cause an overflow error. The following is the wait () source code for your reference.

def wait(hotkey=None, suppress=False, trigger_on_release=False):
    """
    Blocks the program execution until the given hotkey is pressed or,
    if given no parameters, blocks forever.
    """
    if hotkey:
        lock = _Event()
        remove = add_hotkey(hotkey, lambda: lock.set(), suppress=suppress, trigger_on_release=trigger_on_release)
        lock.wait()
        remove_hotkey(remove)
    else:
        while True:
            _time.sleep(1e6)
Menu