How do you read the arrow keys?

Richard Brittain - VOS hacker richard at calvin.ee.cornell.edu
Sat Dec 29 23:45:54 AEST 1990


In article <1990Dec28.195518.26577 at ivy.uucp> iverson at ivy.uucp (Tim Iverson) writes:
>In article <3080 at dali> icsu7039 at nero.cs.montana.edu (Spannring) writes:
>>    I am currently porting some menu routines from MS-DOG to Unix.  
>>What is the proper (terminal independent) way of reading the arrow
>>and/or function keys?
>
>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.

Also, be prepared to make the timeout delay configurable if you want this
to work over a network of any kind.  I have read function keys in several
programs using a 9600 bps direct connect terminal, with no problems, and
using a very short timeout to detect partial escape sequences.  When I
first tried them from a networked workstation via xterm, I couldn't
recognise any sequences because of network delays.  Increasing the timeout
(up to 500ms per byte sometimes) was needed to fix it.
It would certainly be nice if there was a standard library that did this
reliably in all cases.


-- 
Richard Brittain,                 School of Elect. Eng.,  Eng. and Theory Center
                                  Cornell university, Ithaca, NY 14853
INTERNET: richard at calvin.ee.cornell.edu	
    UUCP: {uunet,uw-beaver,rochester,cmcl2}!cornell!calvin!richard



More information about the Comp.unix.programmer mailing list