So I have a loop like this:
import time
for i in range(100):
print(i)
time.sleep(2)
I want to to be able skip an iteration of that loop by pressing a key on the keyboard (for example Enter). The output I expect is:
1
2
3
"Enter" key pressed!
5
Is it possible to do using python?
EDIT: I need to be able to get the keystroke in the background, so that it works while another application is open