Topics

► Games

► Sound & Music

► Watches & Clocks

► GPS

► Power Supplies

► Computers

► Graphics

► Thermometers

► Wearables

► Test Equipment

► Tutorials

► Libraries

► PCB-Based Projects

By processor

AVR ATtiny

► ATtiny10

► ATtiny2313

► ATtiny84

► ATtiny841

► ATtiny85

► ATtiny861

► ATtiny88

AVR ATmega

► ATmega328

► ATmega1284

AVR 0, 1, and 2-series

► ATmega1608

► ATmega4808

► ATmega4809

► ATtiny1604

► ATtiny1614

► ATtiny202

► ATtiny3216

► ATtiny3224

► ATtiny3227

► ATtiny402

► ATtiny404

► ATtiny414

► ATtiny814

AVR DA/DB-series

► AVR128DA28

► AVR128DA32

► AVR128DA48

► AVR128DB28

ARM

► ATSAMD21

► RP2040

► RA4M1

About me

  • About me
  • Twitter
  • Mastodon

Feeds

RSS feed

PS2 Keyboard Scan Codes

The codes generated by the PS/2 keyboard are called scan codes.

Make codes

When a key is pressed a make code is transmitted. Most make codes are a single byte, apart from some extended keys, such as keypad "/", which consist of a two byte sequence consisting of 0xE0 followed by the key's code.

If a key is held down without being released, the make code for that key is sent continuously, at the defined auto-repeat rate.

Break codes

When a key is released an additional scan code is transmitted called a break code. For the single-byte codes the break code consists of the byte 0xF0 followed by the key's make code. For the extended keys the break codes consist of 0xE0, 0xF0 followed by the key's code.

Pause and Prt Scr keys

The Pause and Prt Scr keys are an exception. The Prt Scr key's make code is four bytes, and its break code is six bytes. The Pause key's make code is 8 bytes and starts with 0xE1, and it has no break code.

Scan Code Set 2

Three scan code sets have been defined, but scan code set 2 is used as the default set by all modern PS/2 keyboards. The codes are shown in the following table in hexadecimal:

Key Code: make (break) Key Code: make (break)
ESC 76 (F0 76) K 42 (F0 42)
F1 05 (F0 05) L 4B (F0 4B)
F2 06 (F0 06) ; 4C (F0 4C)
F3 04 (F0 04) ' 52 (F0 52)
F4 0C (F0 0C) Enter 5A (F0 5A)
F5 03 (F0 03) Shift (Left) 12 (F0 12)
F6 0B (F0 0B) Z 1A (F0 1A)
F7 83 (F0 83) X 22 (F0 22)
F8 0A (F0 0A) C 21 (F0 21)
F9 01 (F0 01) V 2A (F0 2A)
F10 09 (F0 09) B 32 (F0 32)
F11 78 (F0 78) N 31 (F0 31)
F12 07 (F0 07) M 3A (F0 3A)
Prt Scr E0 12 E0 7C (E0 F0 7C E0 F0 12) , 41 (F0 41)
Scroll Lock 7E (F0 7E) . 49 (F0 49)
Pause/Break E1 14 77 E1 F0 14 E0 77 (None) / 4A (F0 4A)
` 0E (F0 0E) Shift (Right) 59 (F0 59)
1 16 (F0 16) Ctrl (left) 14 (F0 14)
2 1E (F0 1E) Windows (left) E0 1F (E0 F0 1F)
3 26 (F0 26) Alt (left) 11 (F0 11)
4 25 (F0 25) Spacebar 29 (F0 29)
5 2E (F0 2E) Alt (right) E0 11 (E0 F0 11)
6 36 (F0 36) Windows (right) E0 27 (E0 F0 27)
7 3D (F0 3D) Menus E0 2F (E0 F0 2F)
8 3E (F0 3E) Ctrl (right) E0 14 (E0 F0 14)
9 46 (F0 46) Insert E0 70 (E0 F0 70)
0 45 (F0 45) Home E0 6C (E0 F0 6C)
- 4E (F0 4E) Page Up E0 7D (E0 F0 7D)
= 55 (F0 55) Delete E0 71 (E0 F0 71)
Backspace 66 (F0 66) End E0 69 (E0 F0 69)
Tab 0D (F0 0D) Page Down E0 7A (E0 F0 7A)
Q 15 (F0 15) Up Arrow E0 75 (E0 F0 75)
W 1D (F0 1D) Left Arrow E0 6B (E0 F0 6B)
E 24 (F0 24) Down Arrow E0 72 (E0 F0 72)
R 2D (F0 2D) Right Arrow E0 74 (E0 F0 74)
T 2C (F0 2C) Num Lock 77 (F0 77)
Y 35 (F0 35) / (keypad) E0 4A (E0 F0 4A)
U 3C (F0 3C) * (keypad) 7C (F0 7C)
I 43 (F0 43) - (keypad) 7B (F0 7B)
O 44 (F0 44) 7 (keypad) 6C (F0 6C)
P 4D (F0 4D) 8 (keypad) 75 (F0 75)
[ 54 (F0 54) 9 (keypad) 7D (F0 7D)
] 5B (F0 5B) + (keypad) 79 (F0 79)
\ 5D (F0 5D) 4 (keypad) 6B (F0 6B)
Caps Lock 58 (F0 58) 5 (keypad) 73 (F0 73)
A 1C (F0 1C) 6 (keypad) 74 (F0 74)
S 1B (F0 1B) 1 (keypad) 69 (F0 69)
D 23 (F0 23) 2 (keypad) 72 (F0 72)
F 2B (F0 2B) 3 (keypad) 7A (F0 7A)
G 34 (F0 34) 0 (keypad) 70 (F0 70)
H 33 (F0 33) . (keypad) 71 (F0 71)
J 3B (F0 3B) Enter (keypad) E0 5A (E0 F0 5A)

blog comments powered by Disqus