The key library is a library for acquiring the key press state and setting key control.

The following is an overview of the Key library.

Key code

You can get the key code for keystrokes using the ANSI-C standard function getchar ().

By default, each time you press the [SHIFT] key, the shift state of the keystrokes alternates between "Numeric mode" and "Alphabet mode", and the key codes in the following table are output.
Key Numeric mode Alphabet mode
[SCAN] key
(Trigger key)
SCAN_KEY
TRIGGER_KEY
0x80 SCAN_KEY
TRIGGER_KEY
0x80
[Q1] key Q1_KEY0x81 LEFT_KEY0x86
[Q2] key Q2_KEY0x82 RIGHT_KEY0x87
[BS] key BS_KEY0x85 BS_KEY0x85
[CLEAR] key CLR_KEY0x84 --
[ENT] key ENT_KEY0x0A ENT_KEY0x0A
[SHIFT] key -- --
[0] key NUM0_KEY ('0')0x30 + -0x2B 0x2D
[1] key NUM1_KEY ('1')0x31 SPACE0x20
[2] key NUM2_KEY ('2')0x32 a b c
A B C
0x61 0x62 0x63
0x41 0x42 0x43
[3] key NUM3_KEY ('3')0x33 d e f
D E F
0x64 0x65 0x66
0x44 0x45 0x46
[4] key NUM4_KEY ('4')0x34 g h i
G H I
0x67 0x68 0x69
0x47 0x48 0x49
[5] key NUM5_KEY ('5')0x35 j k l
J K L
0x6A 0x6B 0x6C
0x4A 0x4B 0x4C
[6] key NUM6_KEY ('6')0x36 m n o
M N O
0x6D 0x6E 0x6F
0x4D 0x4E 0x4F
[7] key NUM7_KEY ('7')0x37 p q r s
P Q R S
0x70 0x71 0x72 0x73
0x50 0x51 0x52 0x53
[8] key NUM8_KEY ('8')0x38 t u v
T U V
0x74 0x75 0x76
0x54 0x55 0x56
[9] key NUM9_KEY ('9')0x39 w x y z
W X Y Z
0x77 0x78 0x79 0x7A
0x57 0x58 0x59 0x5A
[.] key DOT_KEY ('.')0x2E , ? ! @ ` -
_ ( ) : ; &
/ % # *
0x2C 0x3F 0x21 0x40 0x60 0x2D
0x5F 0x28 0x29 0x3A 0x3B 0x26
0x2F 0x25 0x23 0x2A
[F1] key F1_KEY0x90 SHIFT_F1_KEY0x94
[F2] key F2_KEY0x91 SHIFT_F2_KEY0x95
[F3] key F3_KEY0x92 SHIFT_F3_KEY0x96

By setting MANUAL_SHIFT_MODE with the SetKeyinputMode function, you can disable the control of the shift state by the OS and get the following key codes.
Key Key code
[SCAN] key
(Trigger key)
SCAN_KEY
TRIGGER_KEY
0x80
[Q1] key Q1_KEY0x81
[Q2] key Q2_KEY0x82
[BS] key BS_KEY0x85
[CLEAR] key CLR_KEY0x84
[ENT] key ENT_KEY0x0A
[SHIFT] key SHIFT_KEY0x8A
[0] key NUM0_KEY ('0')0x30
[1] key NUM1_KEY ('1')0x31
[2] key NUM2_KEY ('2')0x32
[3] key NUM3_KEY ('3')0x33
[4] key NUM4_KEY ('4')0x34
[5] key NUM5_KEY ('5')0x35
[6] key NUM6_KEY ('6')0x36
[7] key NUM7_KEY ('7')0x37
[8] key NUM8_KEY ('8')0x38
[9] key NUM9_KEY ('9')0x39
[.] key DOT_KEY ('.')0x2E
[F1] key F1_KEY0x90
[F2] key F2_KEY0x91
[F3] key F3_KEY0x92

Last updated: 2021/06/30