boppreh / keyboard

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

Using exit(0) inside on_press_key() lambda doesn't exit the program #626

Open 8dcc opened 6 months ago

8dcc commented 6 months ago

If I use the following line:

keyboard.on_press_key("F4", lambda event: print("test"))

The message is printed, but if I try to exit instead, nothing happens at all:

keyboard.on_press_key("F4", lambda event: exit(0))

I also tried using sys.exit(0), but nothing happens.