On Sunday, 8 January 2017 at 21:19:15 UTC, LouisHK wrote:
And works fine, but the D version below nothing happens when I hit ESCAPE:
Different runtimes are free to line buffer data, meaning getch won't actually see anything until you hit enter.
(Actually, the operating system does the buffering unless the runtime specifically asks it not to.)
Looks like your C library (gcc? asks the OS not to buffer, and the D (digital mars or Microsoft, DM on 32 bit, MS on 64 bit) turn it off.
Best solution is to skip those C library functions and do it yourself with the OS-level calls. Then you can turn it off and actually control the buffering behavior.
