bas7ex.hlp (Topic list)
KEY and ON KEY Programming Example
                       Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
'This example uses the KEY and ON KEY statements to trap the CTRL+S
'(control key and lowercase "s") and the down direction key.
 
'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$(&H4) + 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