Lydcn 奕东's 博客
凤凰博报 由你开始
http://lydcn.blog.ifeng.com
发表 管理 分类 简介 头像 功能 音乐 友情链接 模板 个性域名

2006-04-19 00:41:00 编辑 删除

归档在 DOS年代 | 浏览 460 次 | 评论 0 条

Keyboard Scan Codes

 When the keyboard forces a hardware interrupt, it passes a Scan Code to
 the INT 09H interrupt handler.  The handler converts this to an ASCII or
 Extended ASCII value.  For compatibility across the various keyboards, it
 is wise to avoid using scan codes and stick to the BIOS translation of a
 keystroke.

圯Original PC/XT Keyboard捋
  When a key is released, the keyboard sends the same value, ORed with 80H
  (e.g., [Ctrl] sends 1dH when pressed and 9dH when released).

============================================================================
Hex Dec Key Hex Dec Key  Hex Dec Key    Hex Dec Key    Hex Dec Key
============================================================================
01   1  Esc ?2  18  E    ?3  35  H      ?4  52  . >    ?5  69  NumLock
02   2  1 ! ?3  19  R    ?4  36  J      ?5  53  / ?    ?6  70  ScrollLck
03   3  2 @ ?4  20  T    ?5  37  K      ?6  54  Shft(R)?7  71  Home [7]
04   4  3 # ?5  21  Y    ?6  38  L      ?7  55  * PrtSc?8  72  ^    [8]
05   5  4 $ ?6  22  U    ?7  39  ; :    ?8  56  Alt    ?9  73  PgUp [9]
06   6  5 % ?7  23  I    ?8  40  " '    ?9  57  space  ?a  74  K -
07   7  6 ^ ?8  24  O    ?9  41  ` ~    ?a  58  CapsLck?b  75  <    [4]
08   8  7 & ?9  25  P    ?a  42  Shft(L)?b  59  F1     ?c  76       [5]
09   9  8 * ?a  26  [ {  ?b  43  |    ?c  60  F2     ?d  77  >    [6]
0a  10  9 ( ?b  27  ] }  ?c  44  Z      ?d  61  F3     ?e  78  K +
0b  11  0 ) ?c  28  Enter?d  45  X      ?e  62  F4     ?f  79  End  [1]
0c  12  - _ ?d  29  Ctrl ?e  46  C      ?f  63  F5     ?0  80  v    [2]
0d  13  + = ?e  30  A    ?f  47  V      ?0  64  F6     ?1  81  PgDn [3]
0e  14  bksp?f  31  S    ?0  48  B      ?1  65  F7     ?2  82  Ins  [0]
0f  15  Tab ?0  32  D    ?1  49  N      ?2  66  F8     ?3  83  Del  [.]
10  16  Q   ?1  33  F    ?2  50  M      ?3  67  F9     ?11  17  W   ?2  34  G    ?3  51  , <    ?4  68  F10    ?============================================================================
    K indicates a key on the numeric keypad^ (when not in NumLock mode)

圯84-key AT Keyboard捋
  The 84-key keyboard sends the same scan codes as the 83-key (original PC)
  keyboard with the addition that

              [SysReq] sends scan code 54H (84 decimal).

  However, the BIOS never lets an application program see this scan code.
  Instead, it invokes INT 15H 85H on make or break of the SysReq key.

  The 'break' (release of a key) is handled differently.  Upon a break, the
  keyboard sends a two-byte sequence:  0f0H, followed by the 'make' scan
  code.  See AT Keyboard Functions for information on programming this
  keyboard.

圯101-key Keyboard捋
  This keyboard has three separate mappings of the scan codes, selected by
  communication through port 64H.  The keyboard comes to life with scan code
  set 2 (which is wildly different from the 84-key mapping.  However, the
  scan codes are translated by the hardware keyboard interface before they
  are made available to programs that read the keyboard.

  The result is that all of the scan codes identified in the above table are
  valid when the 101-key 'board comes up naturally.  The following table
  lists the additional scan-codes that are sent by the 101-key 'board.  Note
  that all keys mentioned here refer to the keys that are unique to this
  keyboard; e.g., [Insert] is the dedicated insert key (not KeyPad Ins).

  ========================================================================
  Key                       Hex Sequence      ?Key           Hex Sequence
  ========================================================================
  F11 ..................... 57                ?Home ........ e0 47
  F12 ..................... 58                ?Shft-Home ... e0 aa e0 47
  Right-Alt ............... e0 38             ?End ......... e0 4f
  Right-Ctrl .............. e0 1d             ?Shft-End .... e0 aa e0 4f
  PrintScreen ............. e0 2a e0 37       ?^ ........... e0 48
  Shft-PrintScreen (SysReq) e0 37             ?Shft-^ ...... e0 aa e0 48
  Ctrl-PrintScreen (SysReq) e0 37             ?v ........... e0 50
  Alt-PrintScreen ......... 54                ?Shft-v ...... e0 aa e0 50
  Pause ................... e1 1d 45 e1 9d c5 ?PageUp ...... e0 49
  Ctrl-Pause (Break) ...... e0 46 e0 c6       ?Shft-PageUp . e0 aa e0 49
  Insert .................. e0 52             ?PageDown .... e0 51
  Shft-Insert ............. e0 aa e0 52       ?Shft-PageDown e0 aa e0 51
  Delete .................. e0 53             ?> ........... e0 4d
  Shft-Delete ............. e0 aa e0 53       ?Shft-> ...... e0 aa e0 4d
  < ....................... e0 4b             ?K Enter ..... e0 1c
  Shft-< .................. e0 aa e0 4b       ?K / ......... e0 35
                                              ?Shft-K / .... e0 aa e0 35
  ========================================================================
                 K indicates a key on the numeric keypad^

  Note that in cases where a key is similar to another (pre-101) key, the
  second scan code byte is the same as the original key.  Thus, some
  programs that work at the scan-code level can get away with simply
  ignoring the e0H prefix.

See Also: INT 09H
          Keyboard Flags
          Extended ASCII Keystrokes
          INT 16H
                                    -*-

 

-----------------------------------------------

     

Extended ASCII Keystrokes
 When INT 16H Fn 00H returns AL=0, then AH will contain an extended ASCII
 keystroke as listed in these tables.  When a DOS Character I/O function
 returns a character of 00H, you should make a second call to obtain the
 extended ASCII value.

 帜======================================================================姆
 ?Key Hex Dec ?Key       Hex Dec ?Key       Hex Dec ?Key      Hex Dec ? 悄======================================================================亩
 ?F1   3b  59 ?Shift-F1   54  84 ?Ctrl-F1   5e   94 ?Alt-F1   68  104 ? ?F2   3c  60 ?Shift-F2   55  85 ?Ctrl-F2   5f   95 ?Alt-F2   69  105 ? ?F3   3d  61 ?Shift-F3   56  86 ?Ctrl-F3   60   96 ?Alt-F3   6a  106 ? ?F4   3e  62 ?Shift-F4   57  87 ?Ctrl-F4   61   97 ?Alt-F4   6b  107 ? ?F5   3f  63 ?Shift-F5   58  88 ?Ctrl-F5   62   98 ?Alt-F5   6c  108 ? ?F6   40  64 ?Shift-F6   59  89 ?Ctrl-F6   63   99 ?Alt-F6   6d  109 ? ?F7   41  65 ?Shift-F7   5a  90 ?Ctrl-F7   64  100 ?Alt-F7   6e  110 ? ?F8   42  66 ?Shift-F8   5b  91 ?Ctrl-F8   65  101 ?Alt-F8   6f  111 ? ?F9   43  67 ?Shift-F9   5c  92 ?Ctrl-F9   66  102 ?Alt-F9   70  112 ? ?F10  44  68 ?Shift-F10  5d  93 ?Ctrl-F10  67  103 ?Alt-F10  71  113 ? 幽======================================================================慕
 帜======================================================================姆
 ?Key   Hex  Dec?Key   Hex  Dec ?Key      Hex  Dec ?Key      Hex  Dec ? 悄======================================================================亩
 ?Alt-A  1e  30 ?Alt-P  19   25 ?Alt-3     7a  122 ?down  v   50   80 ? ?Alt-B  30  48 ?Alt-Q  10   16 ?Alt-4     7b  123 ?left  <   4b   75 ? ?Alt-C  2e  46 ?Alt-R  13   19 ?Alt-5     7c  124 ?right >   4d   77 ? ?Alt-D  20  32 ?Alt-S  1f   31 ?Alt-6     7d  125 ?up    ^   48   72 ? ?Alt-E  12  18 ?Alt-T  14   20 ?Alt-7     7e  126 ?End       4f   79 ? ?Alt-F  21  33 ?Alt-U  16   22 ?Alt-8     7f  127 ?Home      47   71 ? ?Alt-G  22  34 ?Alt-V  2f   47 ?Alt-9     80  128 ?PgDn      51   81 ? ?Alt-H  23  35 ?Alt-W  11   17 ?Alt--     82  130 ?PgUp      49   73 ? ?Alt-I  17  23 ?Alt-X  2d   45 ?Alt-=     83  131 ?                  ? ?Alt-J  24  36 ?Alt-Y  15   21 ?                  ?^left     73  115 ? ?Alt-K  25  37 ?Alt-Z  2c   44 ?NUL       03    3 ?^right    74  116 ? ?Alt-L  26  38 ?               ?Shift-Tab 0f   15 ?^End      75  117 ? ?Alt-M  32  50 ?Alt-0  81  129 ?Ins       52   82 ?^Home     77  119 ? ?Alt-N  31  49 ?Alt-1  78  120 ?Del       53   83 ?^PgDn     76  118 ? ?Alt-O  18  24 ?Alt-2  79  121 ?^PrtSc    72  114 ?^PgUp     84  132 ? 幽======================================================================慕
             赏==============================================?             ?101-key Keyboard Extensions Supported by BIOS ?   帜==================================================================姆
   ?Key      Hex  Dec ?Key           Hex Dec ?Key           Hex  Dec ?   悄==================================================================亩
   ?F11       85  133 ?Alt-Bksp      0e   14 ? Alt- K /      a4  164 ?   ?F12       86  134 ?Alt-Enter     1c   28 ? Alt- K *      37   55 ?   ?Shft-F11  87  135 ?Alt-Esc       01    1 ? Alt- K -      4a   74 ?   ?Shft-F12  88  136 ?Alt-Tab       a5  165 ? Alt- K +      4e   78 ?   ?Ctrl-F11  89  137 ?Ctrl-Tab      94  148 ? Alt- K Enter  a6  166 ?   ?Ctrl-F12  8a  138 ?                      ?                       ?   ?Alt-F11   8b  139 ?Alt-up     ^  98  152 ?Ctrl- K /      95  149 ?   ?Alt-F12   8c  140 ?Alt-down   v  a0  160 ?Ctrl- K *      96  150 ?   ?Alt-[     1a   26 ?Alt-left   <  9b  155 ?Ctrl- K -      8e  142 ?   ?Alt-]     1b   27 ?Alt-right  >  9d  157 ?Ctrl- K +      90  144 ?   ?Alt-;     27   39 ?                      ?                       ?   ?Alt-'     28   40 ?Alt-Delete    a3  163 ?Ctrl- K ^  [8] 8d  141 ?   ?Alt-`     29   41 ?Alt-End       9f  159 ?Ctrl- K 5  [5] 8f  143 ?   ?Alt-     2b   43 ?Alt-Home      97  151 ?Ctrl- K v  [2] 91  145 ?   ?Alt-,     33   51 ?Alt-Insert    a2  162 ?Ctrl- K Ins[0] 92  146 ?   ?Alt-.     34   52 ?Alt-PageUp    99  153 ?Ctrl- K Del[.] 93  147 ?   ?Alt-/     35   53 ?Alt-PageDown  a1  161 ?                       ?   幽==================================================================慕
      K indicates a key on the numeric keypad^ (when not in NumLock mode)

圯Detecting the press and release of Alt捋
  The BIOS does not put the Alt key or other shift keys into the keyboard
  buffer.  If you want to take notice of the press (and release) of say,
  Alt, you will need to either intercept INT 09H and read the raw scan
  codes, or poll the byte at 0040:0017 regularly and watch for changes to
  the keyboard shift-state flags.

See Also: Keyboard Scan Codes
          Keyboard Flags
          Character I/O Functions
          INT 16H
                                    -*-



 

 

0
上一篇 << 看了N次,笑N次的故事      下一篇 >> 一个普通打工者为买一套房子需要…
  • 暂时还有没评论。
您还没有登录,请登录以后再发表评论。

关于博主

lydcn

终于拥有自己的博客啦!

博文相关