Here's something simpler: import std.stdio : writefln; extern(C) int kbhit(); extern(C) int getch(); void main() { while(!kbhit()) { // keep polling // might use thread.sleep here. } writefln("Key hit was %s.", getch()); }