I would like to stop a loop when I press the space key.
This is what I have tried:
def simulate(self):
for x in range(self.repeat):
if (keyboard.is_pressed('space')):
break
time.sleep(self.timer)
keyboard.write(self.key)
Why is that not working?