Just last night I was having a hard time implementing a global shutdown key for my experiment.
The problem was that once I set the
func argument of
when running the code and pressing the key, a systemexit exception was thrown that I did not catch in the code, therefore preventing the program from shutting down.
As I did not see this problem being mentioned in the documentation, I thought maybe this topic could be of help to some developers facing the same issue.
The solution however is to call the function as below:
event.globalKeys.clear() event.globalKeys.add(key='q', func=os._exit, func_args=, func_kwargs=None)
This will quit the program without raising any exceptions and I think this exception should be mentioned in the documentation.