[prog] reading backspace key

Cliff Crawford cjc26 at cornell.edu
Sun Feb 8 18:36:42 EST 2004


On Sun, Feb 08, 2004 at 03:01:54PM -0600, ed orphan wrote:
> This is bizzare. I can't find a C function 
> that will read in a backspace keys from the
> keyboard. I have tried getc(), getchar(),
> gets(), fgets(), scanf(), and read().
> I must be doing something dumb.
> So can anyone tell me how to read in
> backspace keys using  GNU C ?

getchar() can do this, but you need to set your terminal so that it
immediately sends all keypresses to your program, rather than
buffering them until the user presses Return (which is the default
behavior).  I don't remember exactly how to do this, but the man page
for termios should explain it (look for "canonical mode", which is
what the default behavior is called).


-- 
 Cliff Crawford             ***             cjc26 at cornell.edu

"The perfection of art is to conceal art."      -- Quintilian


More information about the Programming mailing list