Module

input._reader

KeyReader — iterator that yields Key objects from terminal input.

Classes

KeyReader 6 ▼
Iterator that yields Key objects from terminal input. Usage:: with KeyReader() as keys: …

Iterator that yields Key objects from terminal input.

Usage::

with KeyReader() as keys:
    for key in keys:
        if key.name == SpecialKey.ESCAPE:
            break
        print(key)

Methods

read_key 0 Key ▼
Read and return the next keypress.
def read_key(self) -> Key
Returns
Key
Internal Methods 5 ▼
__init__ 1 ▼
def __init__(self, fd: int | None = None) -> None
Parameters
Name Type Description
fd — Default:None
__enter__ 0 KeyReader ▼
def __enter__(self) -> KeyReader
Returns
KeyReader
__exit__ 3 ▼
def __exit__(self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None) -> None
Parameters
Name Type Description
exc_type —
exc_val —
exc_tb —
__iter__ 0 Iterator[Key] ▼
def __iter__(self) -> Iterator[Key]
Returns
Iterator[Key]
__next__ 0 Key ▼
def __next__(self) -> Key
Returns
Key