I wanted to do an action, as soon as my f key is pressed. The problem is that it spams the action.
import win32api while True: f_keystate = win32
You need a state variable that will keep track of whether the key has been pressed after it's been released.
f_pressed = False while not f_pressed: f_pressed = win32api.GetAsyncKeyState(0x46) < 0 print("Pressed!")