import keyboard import time while True: keyboard.press('1') time.sleep(0.050) keyboard.release('1') time.sleep(0.050)