import keyboard

# Define the callback function to track key presses
def on_key_event(e):
    print(f"Key {e.name} {e.event_type}")

# Start listening for key events
keyboard.hook(on_key_event)

# Wait indefinitely so the listener stays active
keyboard.wait('esc')  # The program will stop when the 'esc' key is pressed
