How do you read the arrow keys?

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Sun Dec 30 07:17:47 AEST 1990


In article <1990Dec28.195518.26577 at ivy.uucp> iverson at ivy.uucp (Tim Iverson) writes:
  [ on the problem of interpreting <esc> given escape sequences ]
> This is a failing of every package I've seen that purports to handle arrow
> keys in a device independent manner, although, it's such a basic problem
> that I assume someone somewhere is offering a package that does do it right.

It's really the terminal's fault, not the programmer's fault. Codes
coming from the terminal should be uniquely decodable as untimed byte
streams. In the best situation, no code is a prefix of another.

A terminal could, for example, produce two <esc>s when you hit the
escape key. This solves the problem trivially.

Using timeouts isn't ``doing it right.'' It's an unfortunate kludge to
deal with the failings of current hardware.

---Dan



More information about the Comp.unix.programmer mailing list