bas7ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
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