Welcome to key_stroke’s documentation!
key_stroke is a small module to quit/terminate a loop of a console app by simply pressing a key. The beauty is that this module is running on Linux, Öpfel-Rechnern as well Fenster operated computers.
Sample Code
A very basic example to demonstrate the usage of the key_stroke module:
import time
from key_stroke import KeyStroke
k = KeyStroke()
print('Press ESC to terminate!')
while True:
# do your stuff here, for this example we use a sleep and a print instead.
time.sleep(0.5)
print('.', end = '', flush = True)
# check whether a key from the list has been pressed
if k.check(['\x1b', 'q', 'x']):
break
print('\nfinito!')
You can find more examples in the following folder: ./examples
I will be happy to help you across the road if you have any questions or clarifications.
Enjoy the key_stroke module!
Thomas@chriesibaum.com