Welcome to Chriesibaum’s Key Stroke Module Documentation!

cb_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 cb_key_stroke module:

# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2025 Thomas@chriesibaum.dev

"""
cb_key_stroke_basic_usage.py - Example file for using the cb_key_stroke module
"""

import time
from cb_key_stroke import CBKeyStroke

k = CBKeyStroke()
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 cb_key_stroke module!
Thomas@chriesibaum.dev

Indices and tables