Does one have to use curses to read single characters from keyboard?
Chris Green
cl at isbd.net
Sun Dec 11 08:59:27 EST 2022
Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> Chris Green <cl at isbd.net> writes:
> >Is the only way to read single characters from the keyboard to use
> >curses.cbreak() or curses.raw()? If so how do I then read characters,
>
> It seems that you want to detect keypresses and not read
> characters from a line-buffered console with editing
> features.
>
> Curses is not portable IIRC. A more portable means would
> be to use tkinter with the "bind" function to bind keys.
>
> >All I actually want to do is get 'Y' or 'N' answers to questions on
> >the command line.
>
> answer = input( 'Format drive C: (Y/N)?' )
>
... and therein lies the fundamental problem, you have to type Y or N
followed by Return. See my own follow-up though.
--
Chris Green
ยท
More information about the Python-list
mailing list