Keyboard scan code

When a key is pressed, a mark code is generated and an IRQ1 interrupt is generated.

When the key is released, a break code is generated and an IRQ1 interrupt is generated.

Therefore: when the A key is pressed and released, two IRQ1 interrupts are actually generated

Break is obtained by setting bit7 of the mark code to 1, that is: break = mark + 0x80

 

1、scan code 集

Here only talk about the keyboard code set set 2 in general daily applications (set 1, set 2 and set 3)

  • Basic scan code: Most scan codes are 1 byte.
  • Extended scan code:  guided by  e0 , e1  or  e2
  • Special PrintScreen/SysRq keys: e0 2a e0 37
  • Special Pause/Break key: e1 1d 45 e1 9d c5

 

 

2. Small keyboard scan code table

key

mark(Hex)

break(Hex)

description

NumLock

45

c5

break = mark + 0x80

/

e0 35

e0 b5

The extend scan code is guided by e0

*

37

b7

break = mark + 0x80

-

4a

that

Same as above

7/Home

47

c7

Same as above

8/Up

48

c8

Same as above

9/PgUp

49

c9

Same as above

4/Left

4b

cb

Same as above

5

4c

cc

Same as above

6/Right

4d

cd

Same as above

1/End

4f

cf

Same as above

2/Down

50

d0

Same as above

3/PgDn

51

D1

Same as above

0/Ins

52

d2

Same as above

./Of

53

d3

Same as above

+

4e

this

Same as above

Enter

e0 1c

e0 9c

extend scan code

The <home><Up><PgUp><Left><Right><End><Down><PgDn><Ins><Del> in the keypad is obtained by pressing NumLock and then pressing it.

Therefore, after a <NumLock> mark code is generated, the above-mentioned mark code is generated. Releasing <NumLock> generates another break code.

 

3. Additional key scan code table

key

mark(Hex)

break(Hex)

description

PrintScreen / SysRq

e0 2a e0 37

e0 b7 e0 aa

extend scan code

Scroll Lock

46

c6

Same as above

Pause/Break

e1 1d 45 e1 9d c5

*

Same as above

Insert

e0 52

e0 d2

Same as above

Home

e0 47

e0 c7

Same as above

Page Up

e0 49

e0 c9

Same as above

Delete

e0 53

e0 d3

Same as above

End

e0 4f

e0 cf

Same as above

Page Down

e0 51

e0 d1

Same as above

left

e0 46

e0 c6

Same as above

right

e0 4d

e0 cd

Same as above

up

e0 48

e0 c8

Same as above

down

e0 50

e0 d0

Same as above

Sorry: My understanding of PrintScreen/SysRq and Pause/Break is not thorough. It is not convenient to explain here.

If you know, please leave a message for enlightenment.

 

 

4. Function key scan code table

key

mark(Hex)

break(Hex)

description

<esc>

01

81

scan code

F1

3b

bb

Same as above

F2

3c

bc

Same as above

F3

3d

bd

Same as above

F4

3e

be

Same as above

F5

3f

bf

Same as above

F6

40

c0

Same as above

F7

41

c1

Same as above

F8

42

c2

Same as above

F9

43

c3

Same as above

F10

44

c4

Same as above

F11

57

d7

Same as above

F12

58

d8

Same as above

 

 

5. Scan code table of main keyboard

key

mark

break

key

mark

break

key

mark

break

key

mark

break

~/·

29

a9

<tab>

0f

8f

<scapslock>

3a

ba

<L-shift>

2a

aa

!/1

02

82

q

10

90

a

1e

9e

with

2c

ac

@/2

03

83

w

11

91

s

1f

9f

x

2d

ad

#/3

04

84

e

12

12

d

20

a0

c

2e

ae

$/4

05

85

r

13

93

f

21

a1

v

2f

af

%/5

06

86

t

14

94

g

22

a2

b

30

b0

^/6

07

87

y

15

95

h

23

a3

n

31

b1

&/7

08

88

u

16

96

j

24

a4

m

32

b2

*/8

09

89

i

17

97

k

25

a5

</,

33

b3

(/9

0a

8a

o

18

98

l

26

a6

>/.

34

b4

)/0

0b

8b

p

19

99

:/;

27

a7

?//

35

b5

_/-

0c

8c

{/[

1a

9a

"/'

28

a8

<R-shift>

36

b6

+/=

0d

8d

}/]

1b

9b

<Enter>

1c

9c

<L-ctrl>

1d

9d

|/\

2b

ab

           

<L-alt>

38

b8

<backspace>

0e

8e

           

<space>

39

b9

                 

<R-alt>

e0 38

e0 b8

                 

<R-ctrl>

e0 1d

e0 9d

 

若输入字符“ABCD”有两种方法

(1)按下 <CapsLock> 键后,再输入 abcd 键,再按 <CapsLock> 键

这样会产生一个 <CapsLock> 键 mark 和 break 码,然后依次是 abcd 的 mark 和 break 码, 最后是 <CapsLock> 的 mark 和 break 码

 

(2)按着 <L-shift> 或 <R-shift> 不放,再按 abcd 键,再放开 <L-shift> 或 <R-shift> 键

这样会产生一个 <L-shift> 或 <R-shift> 键的 mark 码,然后依次是 abcd 的 mark 和 break 码,最后是一个 <L-shift> 或 <R-shift> 键的 break 码

Guess you like

Origin blog.csdn.net/wyyy2088511/article/details/108846242
Recommended