I want someone to type words in the console, and autocomplete from a list when they hit "tab" key. However, raw_input
won't return a string until someone hits [Enter].
How do I read characters into a variable until the user hits [Enter]?
*Note: I don't want to use import readline
for autocompletion because of OS issues.
There is an official FAQ entry on this question, for Unix: http://www.python.org/doc/faq/library/#how-do-i-get-a-single-keypress-at-a-time
Edit (copied from Donal Fellows' comment below): "The problem is that the terminal is in “cooked” mode by default (allowing simple line editing) and that to get the keys as they're typed, it has to be placed in “raw” mode." (Thanks!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With