Curses and the arrow keys

Mike Jetzer jetzer at studsys.mu.edu
Mon Aug 27 04:52:18 AEST 1990


In article <1990Aug24.175453.4310 at irscscm.UUCP> mlake at irscscm.UUCP (Marshall Lake) writes:
>I am writing a program which will be taking advantage of curses.
[ . . . ]
>I am doing a getch () and if I get an ESCAPE I do
>another getch ().  If I addch () for each character I get (the ESCAPE
>and the next character) then the cursor moves around properly on the
>screen but the x/y coordinates in the window structure do not follow
>suit.  Curses is recognizing the arrow keys simply as regular
>characters.  Am I naive in thinking that curses is smart enough to
>handle the arrow keys specially?  Should I be moving the cursor
>manually via the move function?

Your naivete could be corrected by reading the manpage on curses.

Performing a keypad() will enable the keypad on most terminals, and when
the user presses an arrow key, the return value will be KEY_DOWN, KEY_UP,
etc.  You can then take the proper action based on the key that the
user actually pressed.


-- 
Mike Jetzer
"And we'll have fun, fun, fun until Daddy takes the keyboard awa-ay..."



More information about the Comp.unix.questions mailing list