import keyboard as kb import winsound as ws while True: if kb.is_pressed('space'): ws.Beep(1000, 10)