[plt-scheme] Scan key code in non-gui mode
nandehutu wrote:
> [...]
> Is it possible to write a routine that can
> detect a pressed key immediately and print out (byte or char) without
> having to press "enter"?
> [...]
Hello,
it is certainly possible, but heavily system dependent.
If you want to do this in a terminal on a POSIX compliant system, I
would suggest using the external stty program to set an appropriate
input/output mode before simply reading characters or bytes from the
terminal device using standard Scheme procedures. An example program is
attached to this message -- save the two modules in the same directory
and run mzscheme -t- keys.ss in a terminal to try it out.
In a Windows terminal window you would have to use some native C API to
achieve the same effect.
Ciao,
Thomas
--
When C++ is your hammer, every problem looks like your thumb.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: keys.ss
URL: <http://lists.racket-lang.org/users/archive/attachments/20100206/4cbf5fce/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: terminal.ss
URL: <http://lists.racket-lang.org/users/archive/attachments/20100206/4cbf5fce/attachment-0001.ksh>