[racket] keyboard input help?

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Tue Sep 21 02:11:00 EDT 2010

Isaiah Gilliland wrote at 09/21/2010 01:16 AM:
> I was wanting to see if there was at all a way to do asynchronous 
> input from a keyboard in racket. Kinda like tcp-listen, that won't 
> freeze up the program while it's used, and won't show in the terminal.

I'm going to assume you're on something Unix-y.

A C library called "curses" is most often used for this sort of 
interface.  In addition to unbuffered keyboard input and disabling echo, 
it will take care of moving the cursor around, and a bunch of other 
things.  Perhaps most importantly, it will insulate you from a lot of 
terminal control languages and quirks that you had no idea existed, some 
of which you'd otherwise bump into eventually.

There are other libraries and approaches at lower levels, but I suspect 
that "curses" is what you want.

People have made FFI bindings from Racket to "curses" in the past, but I 
don't see any in PLaneT right now.

If you don't quickly find bindings to "curses", you can make them 
yourself pretty quickly.  Or even make only the bindings you need, 
adding them as you need them, since the FFI makes that really easy.


Posted on the users mailing list.