Single char input in D

Bob W nospam at aol.com
Tue Feb 28 04:14:53 PST 2006


Correct me if I am wrong, but there seems to be
no native support in D for getting a single char
from the keyboard.

While 'printf' has been elegantly replaced, nothing
as simple as a 'getch' or 'getche' equivalent seems
to exist in D.

The closest I could get to was to rely on Phobos'
std.cstream and using 'din.getch'. It is
currently not documented (unlike 'din.getc'),
but I regarded it as implied that it would work.

Unfortunately 'din.getche' has obviously the
same bug as its C counterpart in dmc - it
simply does not do what it should
(echoed 'getch').

The whole think makes me wondering if I have
overlooked something or if I am the last person
here using D console apps which actually expect
characters from the keyboard without EOLs
attached to them.

Remaining questions are:

- Can I rely on 'din.getch' being available in future,
even though it is not explicitly mentioned in the
Phobos docs?

- Will 'getche' eventually work properly one day?

- Is there any method available/planned in D for
reading extended keycodes from the keyboard?






More information about the Digitalmars-d mailing list