home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap13 / readkey.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-07  |  621 b   |  21 lines

  1. /* readkey.c -- contains the Readkey() function     */
  2. #include <dos.h>
  3. #define KEYINTR 0x16  /* keyboard read interrupt */
  4. #define GETCHAR 0     /* read scancode function  */
  5. struct SCANCODE {
  6.                 unsigned char ascii;  /* ascii code */
  7.                 unsigned char scan;   /* scan code  */
  8.                 };
  9.  
  10. struct SCANCODE Readkey()
  11. {
  12.     union REGS reg;
  13.     struct SCANCODE scancode;
  14.  
  15.     reg.h.ah = GETCHAR;         /* specify function */
  16.     int86(KEYINTR, ®, ®); /* note use of & oper.*/
  17.     scancode.ascii = reg.h.al;
  18.     scancode.scan = reg.h.ah;
  19.     return (scancode);
  20. }
  21.