PWB Extensions Help (ext.hlp) (Table of Contents; 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.
ReadChar
                                             Up Contents Index Back
─────PWB Extensions─────────────────────────────────────────────────────────
 
  Syntax:  long ReadChar( void );
 
  Returns: A long integer containing information about the keystroke.
 
  See:     GetString, ReadCmd
 
     ReadChar waits for the next keystroke and returns it. PWB does not
     echo the keystroke or invoke a function. Once intercepted, the
     keystroke cannot be placed back into the keyboard buffer for
     execution.
 
     The virtual key codes, constants, and macros for handling the
     ReadChar return value are defined in READCHAR.H.
 
     ReadChar returns a long integer composed of two words containing
     information about the keystroke, as follows:
 
     Word        Description
 
     Low word    The ASCII code of the key, or the virtual key code.
 
     High word   The top seven bits of the high word give the keyboard
                 shift and modifier state. The low nine bits of the
                 word specify the virtual key code.
 
     The fields in the high word can be accessed using the following
     masks. Note that they assume a 16-bit unit. Do not use them
     directly with the long value returned from ReadChar.
 
     #define KK_EXTENDED 0x8000  // Key is on extended number pad
     #define KK_CAPLOCK  0x4000  // CAPSLOCK is turned on
     #define KK_NUMLOCK  0x2000  // NUMLOCK is turned on
     #define KK_SCRLOCK  0x1000  // SCROLLLOCK is turned on
     #define KK_ALT      0x0800  // The ALT key is down
     #define KK_CONTROL  0x0400  // The CTRL key is down
     #define KK_SHIFT    0x0200  // The SHIFT key is down
     #define KK_VK       0x01FF  // The virtual key code
 
     You can extract the high word from the long value by using the
     following macro:
 
          #define HIWORD(l) \
                  ((WORD)(((unsigned long)(l) >> 16) & 0xffff))
                                    -♦-