Subj : ESC key in user input To : Nightfox From : Digital Man Date : Sun Feb 07 2010 12:54 pm Re: ESC key in user input By: Nightfox to All on Sat Feb 06 2010 06:02 pm > In writing JavaScript mods for Synchronet, I've noticed some oddness > related to checking for the ESC key in user input. > > I've noticed that there is no key variable defined for ESC in sbbsdefs.js, > so I've always defined it in my own scripts as "\x1b" (alternatively, > defining the ESC key using ascii(27) also seems to work). > > In one script where I use a lightbar user interface, checking for the ESC > key apparently caused the script to quit unexpectedly when scrolling too > fast through the list of items by holding down the up or down arrow keys; > the problem went away when I removed the check for the ESC key. I've also > noticed that Synchronet JavaScript mods tend to take a second or two to > respond to the ESC key, although I've seen that in other doors too, > including older DOS doors (i.e., IceEdit). > > Is there an issue with checking for the ESC key in user input? Yes. Terminal escape sequences (e.g. ANSI) often begin with the escape (ASCII 27) character, for example [2J to clear the screen. > Are the > issues that I've mentioned common, and are there any ways to get around > them (besides not checking for ESC)? You'd have use a timeout mechanism, which explains the delay you see in some scripts/programs that support ESC as a command. digital man Snapple "Real Fact" #155: In 1926, the first outdoor mini-golf courses were built on rooftops in NYC. .