borovsky
borovsky

Reputation: 893

How to read only one character from stdin without waiting for pressing ENTER?

I have CLI implementation for my VisualWorks application. There is "IOAccessor defaultClass stdin" and I want to read one character without waiting for user enter press. It is possible?

in C language there is function like getCh ...

Upvotes: 1

Views: 400

Answers (1)

blabla999
blabla999

Reputation: 3200

This is not a problem of the language: also the C-language getchar() will have to wait. It is a matter of the underlying Operating System's tty-code. On UNIX (eg. Linux), you'd have to change the tty-characteristics to unbuffered, using an stty (old-style) or ioctl call. Under other OSs, similar system calls do similar things.

Upvotes: 3

Related Questions