Get single keystroke?

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Mar 21 14:36:53 PDT 2011


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());
}


More information about the Digitalmars-d-learn mailing list