home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / c / pcpilot.zip / KEYCODES.C < prev    next >
Text File  |  1990-01-13  |  1KB  |  48 lines

  1. /*
  2.     KEYCODES.C - Display scan and ascii keyboard codes
  3. */
  4.  
  5. #include <kbd.h>
  6.  
  7. extern int BorderClr;
  8. extern int TitleClr;
  9. extern int TextClr;
  10. extern int FooterClr;
  11.  
  12. void KeyCodes(void);
  13.  
  14. void KeyCodes()
  15. {
  16.     int Key, HiByte, LoByte;
  17.     char ch;
  18.  
  19.     ScrPush();
  20.     ShadowBox(9,6,28,14, 2, BorderClr);
  21.     PutStr(10,7, TitleClr,   "  Keyboard Codes  ");
  22.     PutStr(9,8, BorderClr,  "╞══════════════════╡");
  23.     PutStr(16,9, FooterClr,        "Scan  Ascii ");
  24.     PutStr(10,10, FooterClr, " Hex:");
  25.     PutStr(10,11, FooterClr, " Dec:");
  26.     PutStr(15,10, TextClr,   "  00    00   ");
  27.     PutStr(15,11, TextClr,   "  00    00   ");
  28.     PutStr(9,12, BorderClr, "╞══════════════════╡");
  29.     PutStr(10,13, FooterClr, "<Esc> twice Quits ");
  30.  
  31.     for (;;)    {
  32.         Key = KbdGetC();
  33.         HiByte = (Key&0xff00) >> 8;
  34.         LoByte = Key&0x00ff;
  35.         ch = LoByte;
  36.         if (ch == 0) ch = ' ';
  37.         PutStr(10,9,  TextClr, "  %c   ", ch);
  38.         PutStr(15,10, TextClr, "  %02X    %02X   ", HiByte, LoByte);
  39.         PutStr(15,11, TextClr, "  %-03d", HiByte);
  40.         PutStr(19,11, TextClr, "    %-03d  ", LoByte);
  41.         if (Key == ESC)    {
  42.             if (KbdGetC() == ESC)    {
  43.                 ScrPop(1);
  44.                 return;
  45.             }
  46.         }
  47.     }
  48. }