Does one have to use curses to read single characters from keyboard?

Grant Edwards grant.b.edwards at gmail.com
Mon Dec 12 13:47:13 EST 2022


On 2022-12-11, Chris Green <cl at isbd.net> wrote:

> Is the only way to read single characters from the keyboard to use
> curses.cbreak() or curses.raw()?

No.

> If so how do I then read characters,

Use a termios.tcsetattr() to put fd 0 into raw mode and then use
os.read().

Recent versions of Python include a "tty" module that has conveniece
functions to handle that:

--
Grant







More information about the Python-list mailing list