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

Alan Gauld learn2program at gmail.com
Mon Dec 12 12:45:21 EST 2022


On 11/12/2022 21:07, dn wrote:
> On 11/12/2022 23.09, Chris Green wrote:
>> 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's not at all obvious from the curses documentation as that seems to
>> think I'm using a GUI in some shape or form.
>>
>> All I actually want to do is get 'Y' or 'N' answers to questions on
>> the command line.
>>
>> Searching for ways to do this produces what seem to me rather clumsy
>> ways of doing it.
> 
> You may like to re-ask this question over on the Python-Tutor list. The 
> ListAdmin over there (literally) wrote the book on Python+curses...
> 
> 
> Did such research include the keyboard module?
> https://pypi.org/project/keyboard/
> 
> This project includes an (Enter-free) "hot-key" feature which firstly 
> detects the specific key or key-combination, and then calls an action 
> if/when True.
> (amongst other functionality)
> 
> Quick read tutorial: 
> https://www.thepythoncode.com/article/control-keyboard-python
> 
> Disclaimer: have had it on my 'radar', but never actually employed.
> (if you have considered, will be interested to hear conclusions...)

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Python-list mailing list