Friday, December 27, 2013

Keyboard Codes and Commands

keyboard-codes-commands
A host system may send 8-bit commands to the keyboard, while a keyboard may send commands and key codes to the system. System commands may be sent to the keyboard at any time. The keyboard will respond within 20 milliseconds, except when performing the basic assurance test (BAT), or executing a Reset command. The table below shows system commands and their hexadecimal values of a keyboard system. 

Command Hex
Set/Reset Status Indicators ED
Echo EE
Invalid Command EF
Select Alternate Scan Codes F0
Invalid Command F1
Read ID F2
Set Typematic Rate/Delay F3
Enable F4
Default Disable F5
Set Default F6
Set All Keys - Typematic - Make/Break - Make -Typematic/Make/Break F7 F8 F9 FA
Set Key Type - Typematic - Make/Break - Make FB FC FD
Resend FE
Reset FF


Keyboard Commands

Table below shows the commands that the keyboard may send to the system and their hexadecimal values.

Command Hex
Key Detection Error/Overrun 00
Keyboard ID 83AB
BAT Completion Code AA
BAT Failure Code FC
Echo EE
Acknowledge (ACK) FA
Resent FE


Keyboard Codes

Keyboard are available for several languages and settings. The keyboard that is most common for the English language is one with 104 keys. Keys of this keyboard are identified by numbers, and for every key there is a scan code. Several scan codes are available, and the default scan code is Scan Code 2 that will discuss here.

Keyboard scan codes consist of a Make and a Break code. The Make code identifies the key pressed and the Break code identifies the release of a key. For most keys the Break code is F0 followed by the Make code. For example, when the Space bar (key 61) is pressed and released, hexadecimal codes 29, F0 and 29 are transmitted from the keyboard to the system via the data serial line. If this key remains pressed, the Make code (29) is continuously transmitted until it is released. Make codes for Scan Code 2 are shown in the table below.
  


Key Numb Make CodeASCII-No Shift ASCII-ShiftCharacter-No Shift Character-Shift
1 0E96 126` ~
2 16 49 331 !
3 1E50 642 @
4 2651 353 #
5 2552 364 $
6 2E53 375 %
7 3654 946 ^
8 3D55 387 &
9 3E56 428 *
10 4657 409 (
11 45 48 410 )
12 4E45 95- _
13 5561 43= +
14 6608 08BS BS
15 0D09 09Tab Tab
16 1581 113Q q
17 1D87 119W w
18 2469 101E e
19 2D82 114R r
20 2C84 116T t
21 3589 121Y y
22 3C/td>85 117U u
23 4373 105I i
24 4479 111O o
25 4D80 112P p
26 5491 123[ {
27 5B93 125] }
28 5D92 124\ |
29 58 Caps Caps
30 1C65 97A a
31 1B83 115S s
32 2368 100D d
33 2B70 102F f
34 3471 103G g
35 3372 104H h
36 3B74 106J j
37 4275 107K k
38 4B76 108L l
39 4C59 58; :
40 5239 34' "
41 5D
42 5A13 EnterEnter Enter
43 12 ShiftShift Shift
44 61 58
45 1A90 122Z z
46 2288 120X x
47 2167 99C c
48 2A86 118V v
49 3266 98B b
50 3178 110N n
51 3A77 109M m
52 4144 60, <
53 4946 62. >
54 4A47 63/ ?
55 59 Shift Shift
56 14 Ctrl Ctrl
57 E01F Win Win
58 11 Alt Alt
59 2932 32Space Space
60 E0/11 Alt Alt
61 E027 Win Win
62 E0/14 Ctrl Ctrl
63 E02F Menu Menu


The Make and Break arrangement, makes it possible for the system to identify multiple keys pressed and the order in which they have been pressed. For example, if one presses and holds down the Left-Shift key (key number 44), 12 Hex is continuously sent to the system. While this is happening, if key number 9 (the 8/* key) is pressed and released, 3E, F0 and 3E codes are transmitted. The receiving system identifies this sequence of events as the intention to enter an asterisk (*).





References:
  • Digital Design and Implementation with Field Programmable Devices, Zainalabedin Navabi, Kluwer Academic Plubishers, 2005.
  • www.acces-is.com (source of image)

No comments:

Post a Comment