<转>键盘扫描码

原文链接:http://www.cnblogs.com/wqw/archive/2009/08/30/1556618.html

 

//以下是一个检测按键扫描码的程序

#i nclude <bios.h>
#i nclude <stdlib.h>
#i nclude <stdio.h>
#define Esc 0x11b
void main(void)
{
  int key;
  while(!kbhit())/*kbhit()表示有键盘按下*/
  {
    key=bioskey(0);/*接收键盘*/
    printf("0x%x"n",key);/*输出扫描码的十六进制形式*/
    if(key==Esc)
      break;
  }
  getch();
}

************************************************************************************

(注:当按下“普通键”时,它的低8位数存放该字符的ASCII码。对于特殊键,低8位为0。特殊键包括箭头键、功能键等。高8位字节存放该键的扫描码。)

扫描码          键
0x011b          ESC
0x3b00          F1
0x3c00          F2
0x3d00          F3
0x3e00          F4
0x3f00          F5
0x4000          F6
0x4100          F7
0x4200          F8
0x4300          F9
0x4400          F10
主键盘区:

0x2960          ~
0x0231          1
0x0332          2
0x0433          3
0x0534          4
0x0635          5
0x0736          6
0x0837          7
0x0938          8
0x0a39          9
0x0b30          0
0x0c2d          -
0x0d3d          =
0x2b5c          "
0x0e08          退格键
0x0f09          Tab
0x1071          q
0x1177          w
0x1265          e
0x1372          r
0x1474          t
0x1579          y
0x1675          u
0x1769          i
0x186f          o
0x1970          p
0x1a5b          [
0x1b5d          ]
0x1e61          a
0x1f73          s
0x2064          d
0x2166          f
0x2267          g
0x2368          h
0x246a          j
0x256b          k
0x266c          l
0x273b          ;
0x2827          '
0x1c0d          回车
0x2c7a          z
0x2d78          x
0x2e63          c
0x2f76          v
0x3062          b
0x316e          n
0x326d          m
0x332c          ,
0x342e          .
0x352f          /
0x3920          空格键
右边数字键盘:

0x5200          Insert
0x4700          Home
0x4900          Page UP
0x5300          Delete
0x4f00          End
0x5100          PageDown
0x4800          上箭头
0x4b00          左箭头
0x5000          下箭头
0x4d00          右箭头
0x352f          /
0x372a          *
0x4a2d          - (注意,这是数字键盘的)
0x4737          7
0x4838          8
0x4939          9
0x4b34          4
0x4c35          5
0x4d36          6
0x4e2b          +
0x4f31          1
0x5032          2
0x5133          3
0x5230          0
0x532e          Del

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/************键盘上各键的扫描码以及组合键的扫描码***************/
#define KEY_L1 0x4F  /*小写键盘上的键*/
#define KEY_L2 0x50
#define KEY_L3 0x51
#define KEY_L4 0x4B
#define KEY_L6 0x4D
#define KEY_L7 0x47
#define KEY_L8 0x48
#define KEY_L9 0x49
#define KEY_ADD 0x2B
#define KEY_SUB 0x2D
#define KEY_LEFT 75      /*左箭头*/
#define KEY_RIGHT 77     /*右箭头*/
#define KEY_UP 72        /*上箭头*/
#define KEY_DOWN 80      /*下箭头*/
#define KEY_F1 59
#define KEY_F2 60
#define KEY_F3 61
#define KEY_F4 62
#define KEY_F5 63
#define KEY_F6 64
#define KEY_F7 65
#define KEY_F8 66
#define KEY_F9 67
#define KEY_F10 68
#define KEY_INSERT 82
#define KEY_HOME 71
#define KEY_PAGEUP 73
#define KEY_PAGEDOWN 81
#define KEY_DEL 83
#define KEY_END 79

#define KEY_DASH 12 /* _- */
#define KEY_EQUAL 13 /* += */
#define KEY_LBRACKET 26 /* {[ */
#define KEY_RBRACKET 27 /* }] */
#define KEY_SEMICOLON 39 /* :; */
#define KEY_RQUOTE 40 /* ' */
#define KEY_LQUOTE 41 /* ~` */
#define KEY_PERIOD 52 /* >. */
#define KEY_COMMA 51 /* <, */
#define KEY_SLASH 53 /* ?/ */
#define KEY_BACKSLASH 43 /* |" */
#define KEY_ENTER 28         /*回车键*/
#define KEY_BACKSPACE 14     /*退格键*/
#define KEY_SPACE 57         /*空格键*/
#define KEY_TAB 15
#define KEY_ESC 1
#define KEY_Q 16
#define KEY_W 17
#define KEY_E 18
#define KEY_R 19
#define KEY_T 20
#define KEY_Y 21
#define KEY_U 22
#define KEY_I 23
#define KEY_O 24
#define KEY_P 25
#define KEY_A 30
#define KEY_S 31
#define KEY_D 32
#define KEY_F 33
#define KEY_G 34
#define KEY_H 35
#define KEY_J 36
#define KEY_K 37
#define KEY_L 38
#define KEY_Z 44
#define KEY_X 45
#define KEY_C 46
#define KEY_V 47
#define KEY_B 48
#define KEY_N 49
#define KEY_M 50
#define KEY_1 2
#define KEY_2 3
#define KEY_3 4
#define KEY_4 5
#define KEY_5 6
#define KEY_6 7
#define KEY_7 8
#define KEY_8 9
#define KEY_9 10
#define KEY_0 11

/+++++++++++++++++++++++++CTR+各键扫描码+++++++++++++++++++++++++/
#define KEY_F1 0x5E
#define KEY_F2 0x5F
#define KEY_F3 0x60
#define KEY_F4 0x61
#define KEY_F5 0x62
#define KEY_F6 0x63
#define KEY_F7 0x64
#define KEY_F8 0x65
#define KEY_F9 0x66
#define KEY_F10 0x67
#define KEY_2 0x03
#define KEY_6 0x1E
#define KEY_Q 0x11
#define KEY_W 0x17
#define KEY_E 0x05
#define KEY_R 0x12
#define KEY_T 0x14
#define KEY_Y 0x19
#define KEY_U 0x15
#define KEY_I 0x09
#define KEY_O 0x0F
#define KEY_P 0x10
#define KEY_LBRACKET 0x1B   /* {[ */
#define KEY_RBRACKET 0x1D   /* }] */
#define KEY_A 0x01
#define KEY_S 0x13
#define KEY_D 0x04
#define KEY_F 0x06
#define KEY_G 0x07
#define KEY_H 0x08
#define KEY_J 0x0A
#define KEY_K 0x0B
#define KEY_L 0x0C
#define KEY_Z 0x1A
#define KEY_X 0x18
#define KEY_C 0x03
#define KEY_V 0x16
#define KEY_B 0x02
#define KEY_N 0x0E
#define KEY_M 0x0D
#define KEY_SPACE 0x20
#define KEY_BACKSPACE 0x7F
#define KEY_ENTER 0x0A
#define KEY_BACKSLASH 0x1C  /* |" */
#define KEY_L1 0x75  /*小写键盘上的键*/
#define KEY_L3 0x76
#define KEY_L4 0x73
#define KEY_L6 0x74
#define KEY_L7 0x77
#define KEY_L9 0x84

/+++++++++++++++++++++++++SHIFT+各键扫描码+++++++++++++++++++++++++/
#define KEY_LQUOTE 0x7E   /* ~` */
#define KEY_1 0x21
#define KEY_2 0x40
#define KEY_3 0x23
#define KEY_4 0x24
#define KEY_5 0x25
#define KEY_6 0x5E
#define KEY_7 0x26
#define KEY_8 0x2A
#define KEY_9 0x28
#define KEY_0 0x29
#define KEY_DASH 0x5F   /* _- */
#define KEY_EQUAL 0x2B  /* += */
#define KEY_BACKSPACE 0x08
#define KEY_Q 0x51
#define KEY_W 0x57
#define KEY_E 0x45
#define KEY_R 0x52
#define KEY_T 0x54
#define KEY_Y 0x59
#define KEY_U 0x55
#define KEY_I 0x49
#define KEY_O 0x4F
#define KEY_P 0x50
#define KEY_LBRACKET 0x7B  /* {[ */
#define KEY_RBRACKET 0x7D  /* }] */
#define KEY_ENTER 0x0D
#define KEY_A 0x41
#define KEY_S 0x53
#define KEY_D 0x44
#define KEY_F 0x46
#define KEY_G 0x47
#define KEY_H 0x48
#define KEY_J 0x4A
#define KEY_ENTER 0x1c
#define KEY_SPACE 0x39
#define KEY_UP 0x48
#define KEY_LEFT 0x4b
#define KEY_RIGHT 0x4d
#define KEY_DOWN 0x50 

 

posted @ 2016-01-01 22:23  zh89233  阅读(3798)  评论(0编辑  收藏  举报