Skip to content Skip to sidebar Skip to footer

Is It Still True That With Python3 In Windows It Is Impossible To Input A Single Character From The Screen Without Hitting Enter?

It can be done with termios under Unix, but not under Windows. I do it easily in perl with TERM::Readkey, or in Windows Batch files. If an answer has been given here, I have been u

Solution 1:

The answer above returns a byte, not a character, so it needs to be decoded.

Here is a solution that returns a single character without having to hit Enter. It works in python 3.4, on Windows

def getChar():
    import msvcrt 
    return msvcrt.getch().decode('utf-8')

Post a Comment for "Is It Still True That With Python3 In Windows It Is Impossible To Input A Single Character From The Screen Without Hitting Enter?"