How do you read the arrow keys?

John Temples john at jwt.UUCP
Sun Dec 30 04:05:47 AEST 1990


In article <1990Dec28.195518.26577 at ivy.uucp> iverson at ivy.uucp (Tim Iverson) writes:
>There're going to be alot of responses about getting curses to decode your
>keys for you.  And, yes, it will do it, but it has a major problem: no
>timeouts; e.g. left arrow on a vt100 (or pc ansi console) is <esc>[D, so if
>your user hits <esc>, curses waits for the next char to come along before
>it knows to return the <esc> as a key.

>From the System V/386 Release 3.2 curses man page, under getch():

"If keypad(win, TRUE) has been called, and a function key is pressed,
the token for that function key will be returned instead of the raw
characters.  [...]  If a character is received that could be the
beginning of a function key (such as escape), curses will set a
timer.  If the remainder of the sequence is not received within the
designated time, the character will be passed through, otherwise the
function key value will be returned."

I've used this in curses programs I've written which accept both
cursor keys and the escape key as input, and it works fine.  I guess
it's only available in certain versions of curses?
-- 
John W. Temples -- john at jwt.UUCP (uunet!jwt!john)



More information about the Comp.unix.programmer mailing list