Just starting out

Dmitry Olshansky dmitry.olsh at gmail.com
Tue Oct 18 04:16:03 PDT 2011

On 14.10.2011 4:49, Nick Sabalausky wrote:

> That would be neat.
> One thing I'd been thinking of adding to mine was an alternate function that
> just waited for a single keystroke (rather than a line of text + Enter). I
> think I once had it working on Tango, IIRC, but then I switched to D2/Phobos
> and couldn't figure out how to use Phobos to wait for a single keystroke w/o
> then waiting for Enter.

I used the following trick on Linux, and I think it should work on any 
posix: call select on stdin i.e. fd_set with one descriptor for reading 
- 0 and timeout of 0. This way you'd get something close to a test for 
However that will check if there is a data in stream, so it's quite 
possible to hit any number of "press any key" in advance, so some 
flushing of input in the "wait till keypress" function is needed.

Dmitry Olshansky

More information about the Digitalmars-d mailing list