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: | Chris Crash |
---|---|
Location: | Huntington Beach, CA. |
Users: | 578 |
Nodes: | 8 (0 / 8) |
Uptime: | 29:04:43 |
Calls: | 10,736 |
Calls today: | 1 |
Files: | 5 |
Messages: | 443,191 |
Posted today: | 1 |