# _reader

URL: /milo-cli/api/milo/input/_reader/
Section: input
Description: KeyReader — iterator that yields Key objects from terminal input.

---

> For a complete page index, fetch /milo-cli/llms.txt.

Open LLM text
(/milo-cli/api/milo/input/_reader/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2Finput%2F_reader%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2Finput%2F_reader%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2Finput%2F_reader%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2Finput%2F_reader%2Findex.txt)

Module

#
`input._reader`

KeyReader — iterator that yields Key objects from terminal input.

1Class

## 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`
