I wrote this code on to observe the event of a keydown motion. The problem appears to be that when this script is run, certain programs will crash this program, spitting out
If only 1 out of each 2 presses works, it's definetely a problem with missing return value. Try returning either True or False.