• ESC key in user input

    From Nightfox@VERT/DIGDIST to All on Saturday, February 06, 2010 18:02:34
    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)?

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS: digdist.bbsindex.com
  • From Digital Man@VERT to Nightfox on Sunday, February 07, 2010 12:54:03
    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 <ESC>[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.

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Nightfox@VERT/DIGDIST to Digital Man on Sunday, February 07, 2010 14:39:17
    Re: ESC key in user input
    By: Digital Man to Nightfox on Sun Feb 07 2010 12:54:03

    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.

    Thanks.

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS: digdist.bbsindex.com