qb45advr.hlp (Topic list)
KEY(n) Statement Programming Example
  QuickSCREEN      Details     Example      Contents      Index
──────────────────────────────────────────────────────────────────────────────
KEY(n) Statement Programming Example
 
This example traps the DOWN direction key and CTRL+S (control key and
lowercase "s"). To trap the combination of the CTRL key and uppercase
"s", trap CTRL+SHIFT and CTRL+CAPS-LOCK+s.
 
     Note: Do not run this example with the NumLock key depressed.
 
I = 0
CLS    ' Clear screen
PRINT "Press DOWN direction key to end."
KEY 15, CHR$(&H04) + CHR$(&H1f)
KEY(15) ON              'Trap CTRL+s.
KEY(14) ON              'Trap DOWN direction key.
ON KEY(15) GOSUB Keytrap
ON KEY(14) GOSUB Endprog
Idle: GOTO Idle        'Endless loop
 
Keytrap:   'Counts the number of times CTRL+s pressed.
    I = I + 1
RETURN
 
Endprog:
    PRINT "CTRL+s trapped"; I; "times"
    END
RETURN