undefined identifier getch()

Stewart Gordon smjg_1998 at yahoo.com
Wed Dec 8 07:15:28 PST 2010


On 08/12/2010 13:25, Nrgyzer wrote:
> Okay, but what function can I use to get the pressed key?
> kbhit/_kbhit seems to do what I want, but hwo can I use it in D? I
> always get the error, that kbhit (or similar functions) are not
> available.
<snip>

kbhit just tests whether there's a keystroke waiting in the keyboard 
buffer.  It doesn't identify the key pressed.

If you want to wait for the user to press a key, use getch.

If you want to test whether the user has pressed a key, use kbhit, then 
use getch to determine what key was pressed.

For some reason, this seems to work reliably only on ASCII character 
keys, backspace, tab and carriage return.  But this might be partly due 
to bugs in the DM implementation.

Stewart.


More information about the Digitalmars-d-learn mailing list