How to monitor keydown and keyup in Python?

You should be able to figure out the problem by placing a breakpoint in the OnKeyDownEvent function and stepping through your code. If the people reading this post don’t know how to use the debugger in python, I would highly recommend learning about it. That is one of the most useful tools available to anyone writing code.