[comp.sources.d] was that F17 or ESC 7 ...?

chris@mimsy.UUCP (Chris Torek) (06/26/87)

>In article <5741@think.UUCP> barmar@think.uucp (Barry Margolin) writes:
>>... Some of the function keys even send ESC <digit>!

In article <340@pcrat.UUCP> rick@pcrat.UUCP (Rick Richardson) writes:
>The usual way [to tell the difference between ESC <digit> and the
>function key that sends ESC <digit>] is for the program to issue
>a read [with timeout] ... whenever an ESCAPE character has just
>been read.  If the [timeout] is set to 1/10 second....  This procedure
>works very well, and I use it in UniTalk to diffentiate Function and
>Meta keys....

vi, too, uses this technique.  It fails in two important cases:
Under heavy system load, vi may not wake up until the user has
typed not only the escape, but also several more characters.  This
is not a problem on single threaded machines.  The other case,
however, may indeed cause trouble.  If the user is at the far end
of a high-delay network connection, the network may decide to delay
transmission of an escape, sending it only along with several other
input characters.  Repacketisation (what a word!) and other network
vagaries will do this at the most inconvenient times imaginable.

(The third obvious case, that of a fast typist, does not in fact
occur in practise.  Human operators learn very quickly to separate
escapes from following characters.  Even vi's one second timeout
soon becomes unnoticeable.)

The truly sensible solution is to keep all input events separate.
No two keys should send the same codes!  Ideally, even the two
shift keys should be distinguishable.  The Sun keyboards, which
transmit separate up and down transitions for every keystroke, are
faultless in this regard.  And of course, every input event should
be distinguishable from flow control.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
Domain:	chris@mimsy.umd.edu	Path:	seismo!mimsy!chris