별의 공부 블로그 🧑🏻‍💻
728x90
728x170

키 코드(Key Code) 정리 (키보드 이벤트)

들어가며

  • 자바스크립트에서 사용할 수 있는 키 코드(Key Code)를 정리해본다.

 

키 코드(Key Codes)

Key Code Key Code Unicode Description
0   Unidentified   These keys do not have a key code
3 Cancel Pause   break
8 Backspace Backspace backspace / delete
9 Tab Tab tab
12 Clear NumLock clear
13 Enter Enter Enter / Return
16 Shift ShiftLeft shift
17 Control ControlLeft    
18 Alt AltLeft ⎇ / ⌥ Alt / Option
19 Pause Pause   pause/break
20 CapsLock CapsLock caps lock
21 Unidentified Lang1   hangul
25 Unidentified Lang2   hanja
27 Escape Escape escape
28       conversion
29       non-conversion
32   Space   spacebar
33 PageUp Numpad9 page up
34 PageDown Numpad3 page down
35 End Numpad1   end
36 Home Numpad7 home
37 ArrowLeft ArrowLeft left arrow
38 ArrowUp ArrowUp up arrow
39 ArrowRight ArrowRight right arrow
40 ArrowDown ArrowDown down arrow
41       select
42       print
43       execute
44 F13 F13 Print Screen / F13 (firefox)
45 Insert Numpad0 x insert
46 Delete NumpadDecimal delete
47     help
48 0 Digit0 0
49 1 Digit1 1 Key
50 2 Digit2 2 Key
51 3 Digit3 3 Key
52 4 Digit4 4 Key
53 5 Digit5 5 Key
54 6 Digit6 6 Key
55 7 Digit7 7 Key
56 8 Digit8 8 Key
57 9 Digit9 9 Key
58 : Period   :
59 ; Semicolon   semicolon (firefox), equals
60 < Backquote   <
61 = Equal   equals (firefox)
63 ß Minus   ß
64       @ (firefox)
65 a KeyA   a
66 b KeyB   b
67 c KeyC   c
68 d KeyD   d
69 e KeyE   e
70 f KeyF    
71 g KeyG   g
72 h KeyH   h
73 i KeyI   i
74 j KeyJ   j
75 k KeyK   k
76 l KeyL   l
77 m KeyM   m
78 n KeyN   n
79 o KeyO   o
80 p KeyP   p
81 q KeyQ   q
82 r KeyR   r
83 s KeyS   s
84 t KeyT   t
85 u KeyU   u
86 v KeyV   v
87 w KeyW   w
88 x KeyX   x
89 y KeyY   y
90 z KeyZ   z
91 Meta MetaLeft ⌘ ⊞ Windows Key / Left ⌘ / Chromebook Search key
92 Meta MetaRight ⌘ ⊞ Right Windows
93 ContextMenu ContextMenu Windows Menu / Right ⌘
95     sleep
96 0 Numpad0 Number Pad 0
97 1 Numpad1 Number Pad 1
98 2 Numpad2 Number Pad 2
99 3 Numpad3 Number Pad 3
100 4 Numpad4 Number Pad 4
101 5 Numpad5 Number Pad 5
102 6 Numpad6 Number Pad 6
103 7 Numpad7 Number Pad 7
104 8 Numpad8 Number Pad 8
105 9 Numpad9 Number Pad 9
106 * NumpadMultiply × multiply
107 + NumpadAdd   add
108 , NumpadDecimal   numpad period (firefox)
109 - NumpadSubtract   subtract
110 . NumpadDecimal   decimal point
111 / NumpadDivide ÷ divide
112 F1 F1   f1
113 F2 F2   f2
114 F3 F3   f3
115 F4 F4   f4
116 F5 F5   f5
117 F6 F6   f6
118 F7 F7   f7
119 F8 F8   f8
120 F9 F9   f9
121 F10 F10   f10
122 F11 F11   f11
123 F12 F12    
124 F13 F13   f13
125 F14 F14   f14
126 F15 F15   f15
127 F16 F16   f16
128 F17 F17   f17
129 F18 F18   f18
130 F19 F19   f19
131 F20 F20   F20
132 F21 F21   F21
133 F22 F22   F22
134 F23 F23   F23
135 F24 F24   F24
136 F25 F25   F25
137 F26 F26   F26
138 F27 F27   F27
139 F28 F28   F28
140 F29 F29   F29
141 F30 F30   F30
142 F31 F31   F31
143 F32 F32   F32
144 NumLock NumLock num lock
145 ScrollLock ScrollLock scroll lock
151       airplane mode
160 [ BracketLeft   ^
161 Dead BracketRight   !
162       ؛ (arabic semicolon)
163 \ Backquote   #
164 $ Backslash   $
165 Quote   ù
166       page backward
167       page forward
168       refresh
169 ) Minus   closing paren (AZERTY)
170 * Backslash   *
171 + BracketRight   ~ + * key
172       home key
173 - Minus   minus (firefox), mute/unmute
174 AudioVolumeDown     decrease volume level
175 AudioVolumeUp     increase volume level
176 MediaTrackNext MediaTrackNext   next
177 MediaTrackPrevious MediaTrackPrevious   previous
178       stop
179 MediaPlayPause     play/pause
180 LaunchMail   e-mail
181 AudioVolumeMute VolumeMute   mute/unmute (firefox)
182 AudioVolumeDown VolumeDown   decrease volume level (firefox)
183 AudioVolumeUp VolumeUp   increase volume level (firefox)
186 ; Semicolon   semi-colon / ñ
187 + Equal   equal sign
188 , Comma   comma
189 - Minus   dash
190 . Period   period
191 / Slash   forward slash / ç
192 ` Backquote   Backtick / grave accent / ñ / æ / ö
193 / IntlRo   ?, / or °
194 . NumpadComma   numpad period (chrome)
219 [ BracketLeft   open bracket
220 \ Backslash   back slash
221 ] BracketRight   close bracket / å
222 ' Quote   single quote / ø / ä
223 ` Backquote   `
224 Meta OSLeft left or right ⌘ key (firefox)
225 AltGraph AltRight ⎇ or ⌥ altgr
226 \ IntlBackslash   < /git >, left back slash
230       GNOME Compose Key
231       ç
233       XF86Forward
234       XF86Back
235       non-conversion
240       alphanumeric
242       hiragana/katakana
243       half-width/full-width
244       kanji
251       unlock track pad (Chrome/Edge)
255 Unidentified WakeUp   toggle touchpad

 

사용 방법

  • 다음과 같이 e.keyCode == 키코드 형식으로 사용한다.
function example(e) {
    if (e.keyCode == 18) {
        alert('ALT Key is pressed!');
    }
}

 

  • 다음과 같이 다양한 방법으로 키 코드를 처리할 수 있다. 
event.keyCode == 18;     // 방법 1
event.key == "Alt";      // 방법 2
event.altKey;            // 방법 3

 

참고

 

JavaScript Key Code List & Table | Toptal®

 

www.toptal.com

 

728x90
그리드형(광고전용)

'Programming > JavaScript' 카테고리의 다른 글

이벤트 객체 (Event Object)  (0) 2017.05.21
이벤트 (Event)  (0) 2017.05.21
함수 (Function)  (0) 2017.05.20
문서 객체 모델(DOM)  (0) 2017.05.20
브라우저 객체 모델(BOM)  (0) 2017.05.20
객체 / 내장객체  (0) 2017.05.20
자바스크립트 기초 문법  (0) 2017.05.20
쿠키(Cookie)  (0) 2017.05.18
⚠️AdBlock이 감지되었습니다. 원할한 페이지 표시를 위해 AdBlock을 꺼주세요.⚠️
starrykss
starrykss
별의 공부 블로그 🧑🏻‍💻


📖 Contents 📖