INKEY$ Fails with Various CTRL, ALT Key Combinations QB 4.00 (63781)






This article was previously published under Q63781

SYMPTOMS

The INKEY$ statement fails to return any value with certain CTRL and ALT key combinations that should return extended (2-byte) codes. The table below lists the keys that fail to return values:
   CTRL+                         ALT+
   -----                         ----

   TAB                           ` (back apostrophe)
   INS (INSert)                  BACKSPACE
   DEL (DELete)                  TAB
   Keypad 5                      [ and ]
   Keypad /                      ; and "
   Keypad *                      , and . and / 
   Keypad -                      ENTER
   Keypad +                      Keypad / * - and +
				

STATUS

Microsoft has confirmed this problem with Microsoft QuickBasic versions 4.00, 4.00b, and 4.50, and Microsoft Basic Compiler versions 6.00 and 6.00b for MS-DOS and OS/2 (buglist6.00, buglist6.00b). The problem does not occur with earlier versions of Microsoft Basics. This problem was corrected in Microsoft Basic Professional Development System (PDS) version 7.00 (fixlist7.00).

MORE INFORMATION

Function keys, editing keys, and most CTRL and ALT key combinations should be returned from INKEY$ as a two-character code where the first character is a null character (CHR$(0)) and the second character identifies the key pressed.

Code Example

The following code example demonstrates how to examine key codes for any type of key:
   WHILE i$ <> CHR$(27)   'Exit with ESC (ESCape) key
      i$ = INKEY$
      SELECT CASE LEN(i$)  'Type of key depends on length
         CASE 1:
             PRINT "Single character:", ASC(i$), i$
         CASE 2:
             PRINT "Double character:", ASC(RIGHT$(i$,1))
         CASE ELSE
             REM no key pressed
      END SELECT
   WEND
   END
				

Modification Type: Minor Last Reviewed: 1/8/2003
Keywords: KB63781