advr.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.
Declaring User-Defined Keys
                                                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
 Declaring User-Defined Keys
 
 ■ In addition to providing the pre-assigned key numbers 1-14 (plus 30 and 31
   with the 101-key keyboard), Visual Basic allows you to create user-defined
   keys.
 
 ■ User-defined keys can be assigned to the numbers 15-25 or to any other
   unused keys on the keyboard. See: KEY Statement (Assignment)
 
 ■ You can also set a trap for "shifted" keys. A key is shifted when you
   press it simultaneously with one or more of the special keys Shift, Ctrl,
   or Alt, or if you press it after pressing NumLock or Caps Lock. Use the
   KEY statement to define shifted keys before you can trap them.
 
 ■ You can add the values in the Keyboard Flag Table together to test for
   multiple shift states. A keyboard flag value of 12 would test for both
   Ctrl and Alt being pressed. See: Keyboard Flag Table
 
 ■ To define Shift, Ctrl, Alt, NumLock, or Caps Lock as a user-defined key
   (by itself, not in combination with another key), use a keyboard flag of
   0. For example, to define Alt as a user-defined key:
 
         KEY CHR$(0) + CHR$(56)
 
 ■ To define Alt+Alt as a user-defined key:
 
         KEY CHR$(8) + CHR$(56)
 
   Note: The second Alt will be trapped as it is pressed only if the first
   Alt key is already pressed.
 
 ■ Because key trapping assumes the left and right Shift keys are the same,
   you can use either 1, 2, or 3 to indicate a Shift key. The scancode
   argument is a number identifying one of the 83 keys to trap, as shown in
   the scan code table. See: Keyboard Scan Codes