Detecting Key Presses using win32api in Python
问题 I'm trying to break a loop in Python with a specific key press using win32api. How would one go about this? What is the actual version of win32api.KeyPress('H') , in the following code? Revised: import win32api while True : cp = win32api.GetCursorPos() print cp if win32api.KeyPress('H') == True : break I want to be able to break a loop by pressing the h key. Edit: I'm attempting to make a program that repeatedly reports mouse positions and I need a mechanism to exit said program. See revised