IntroductionMTB StatementsFile SystemCompilerApplicationsReference GuideIndex

Scan Codes

MTB supports direct interception of special keys (function keys, control keys, directional keys, etc.) by using the standard hardware scan codes.

For example, the scan code for the PgUp key is 73 (hex "@49@"), and the scan code for the left arrow is 75 (hex "@4B@").

There are two scan modes available:

  1. partial scan mode (see Partial Scan Codes)
  2. full scan mode (see Full Scan Codes)

The following mnemonics set the scan code modes:

  1. (Partial Scan Codes On)
  2. (Full Scan Codes Passed)

When either of these modes is turned on, pressing one of the special keys interrupts the MTB program waiting for data, and passes the scan code to the waiting data variable.

     PRINT (0) (Partial Scan Codes On)  ! set mode
     .
     INPUT (0) DATA$     ! wait for input or special key

The scan code is made up of 2 bytes. The first bytes is a hex "@00@" is a scan code follows, and the second byte is the scan code itself (in hex). If the first byte is not "@00@" you can assume that the transmit contains data (and not a scan code).

     LENGTH 2 & LOCAL DATA$
     .
     PRINT (0) (Partial Scan Codes On)  ! set mode
     .
     INPUT (0) DATA$     ! wait for input or special key

     IF SUB(DATA$,1,1) NE "@00@" THEN GOTO PROCESS

     IF SUB(DATA$,2,1) EQ "@49@" THEN.. ! PgUp key

     IF SUB(DATA$,2,1) EQ "@4B@" THEN.. ! left arrow
     .
     .
     PROCESS:                           ! data value