import time keyboard = Controller() time.sleep(2) keyboard.press('w') time.sleep(2) keyboard.release('w')