Site hosted by Angelfire.com: Build your free website today!
NAME
  KEY, ON KEY Statements (Event Trapping)

SYNOPSIS
  KEY(n%) ON
  KEY(n%) OFF
  KEY(n%) STOP
  ON KEY(n%) GOSUB line
      o n%              A value that specifies a function key, direction key,
                        or user-defined key:
                        n%        Key
                        ------    --------------------------------------------
                        0         All keys listed here (KEY(0) ON, KEY(0) OFF,
                                  and KEY(0) STOP only).
                        1-10      Function keys F1-F10.
                        11        Up Arrow key.
                        12        Left Arrow key.
                        13        Right Arrow key.
                        14        Down Arrow key.
                        15-25     User-defined keys. For more information,
                                  see  Declaring User-Defined Keys .
                        30, 31    Function keys F11 and F12.
      o KEY(n%) ON      Enables event trapping for the specified key.
      o KEY(n%) OFF     Disables key event trapping.
      o KEY(n%) STOP    Suspends key event trapping. Events are processed
                        once event trapping is enabled by KEY ON.
      o line            The label or number of the first line of the
                        event-trapping subroutine.

DESCRIPTION
  KEY enables, disables, or suspends event trapping of a key.
  If event trapping is enabled, ON KEY branches to a subroutine whenever
  the key is pressed.

  Example:
      'This example requires Caps Lock and Num Lock to be off.
      CONST ESC = 27
      KEY 15, CHR$(&H4) + CHR$(&H1F)              'Set up Ctrl+S as KEY 15.
      ON KEY(15) GOSUB PauseHandler
      KEY(15) ON
      WHILE INKEY$ <> CHR$(ESC)
          PRINT "Press Esc to stop, Ctrl+S to pause."
          PRINT
      WEND
      END
      PauseHandler:
          SLEEP 1
          RETURN

SEE ALSO
  KEY (Assignment) Declaring Keys