Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo Basic - <b>on key trap for keypress</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
ON KEY                   Trap for Keypress

 ON KEY(n) GOSUB {linenum | linelabel}

    Establishes a subroutine to which Turbo Basic will branch if it
    detects a specified keypress. The trap must also be turned on by means
    of a KEY(n) ON statement.

           n    A numeric expression in the range 1 to 31, specifying the
                key to trap, as follows:

                1-10,30,31    Function keys F1 through F10, F11, F12
                11            Cursor Up
                12            Cursor Left
                13            Cursor Right
                14            Cursor Down
                15-25         Keys defined via KEY n, CHR$(KBflag) +
                                                      CHR$(scancode)

     linenum    The first line of a keypress-handling subroutine. Setting
                linenum to 0 disables trapping.

   linelabel    A label identifying the first line of a keypress-handling
                routine.

   -------------------------------------------------------------------------

      Notes:    When the keypress is detected, Turbo Basic branches to the
                specified subroutine and temporarily suspends trapping (by
                means of an implicit KEY(n) STOP statement). Trapping
                automatically resumes when a RETURN from the handling
                subroutine is executed (unless the handler explicitly
                performs a KEY(n) OFF or KEY(n) STOP).

                The key that produced the trap may not be determined by
                means of INPUT$ or INKEY$.

                ON KEY(n) may be used to trap Ctrl-Break and Ctrl-Alt-Del,
                thereby preventing a user from breaking out of a program.

                With event trapping in effect, Turbo Basic checks for the
                specified event after each program statement. The $EVENT
                metastatement can be used to turn event trapping on and
                off at specified points within a program.

See Also: $EVENT KEY(n)

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson