[racket] keyboard input help?

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Tue Sep 21 03:36:15 EDT 2010

I haven't tested the following with Racket 5.x, but either they'll work 
or give you some idea of how easy the FFI makes many things:


Note: There is also a "curses.c" in Racket 5.0.1 
"collects/mzscheme/examples/".  This uses a ``C extension'' instead of 
the FFI.  I suggest using the FFI instead of a C extension, so that you 
can work in Racket code only and won't have to build or maintain C code.

Writing "curses" bindings is a popular recreational activity, and I'd 
bet that multiple people have done it for the FFI, but perhaps someone 
can spoil everyone else's fun by putting pre-made "curses" bindings into 

Neil Van Dyke wrote at 09/21/2010 02:11 AM:
> 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.