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?
Are the
issues that I've mentioned common, and are there any ways to get around
them (besides not checking for ESC)?
Yes. Terminal escape sequences (e.g. ANSI) often begin with the escape (ASCI 27) character, for example <ESC>[2J to clear the screen.
You'd have use a timeout mechanism, which explains the delay you see in some scripts/programs that support ESC as a command.
Sysop: | fluid |
---|---|
Location: | wickliffe, ohio |
Users: | 5 |
Nodes: | 10 (0 / 10) |
Uptime: | 202:32:29 |
Calls: | 50 |
Files: | 15,838 |
Messages: | 50,758 |