PyCharm: msvcrt.kbhit () and msvcrt.getch () not working?

I tried to read one char from the console in PyCharm (without pressing the enter key), but to no avail. The msvcrt.getch() functions stop the code, but do not respond to keystrokes (even input), and msvcrt.kbhit() always returns 0. For example, this code does not print anything:

 import msvcrt while 1: if msvcrt.kbhit(): print 'reading' print 'done' 

I am using Windows 7, PyCharm 3.4 (the same standby heppens).

What's wrong? Is there any other way to just read input without input?

+8
pycharm msvcrt getch kbhit
source share
1 answer

This is possible in a special Run window mode.

  • Select the Emulate terminal in output console checkbox in Run/Debug Configurations
+2
source share

All Articles