Have a look at my demo project: Simple Demo Project to show how to implement continuous mouse and key presses in PsychoPy