1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/events/ozone/layout/layout_util.h"
9 #include "ui/events/event_constants.h"
10 #include "ui/events/keycodes/dom3/dom_code.h"
11 #include "ui/events/keycodes/dom3/dom_key.h"
12 #include "ui/events/keycodes/keyboard_code_conversion.h"
18 // This table, used by DomKeyToKeyboardCode(), maps DOM Level 3 .code
19 // values to legacy Windows-based VKEY values, where the VKEYs are
20 // interpreted positionally.
21 const struct DomCodeToKeyboardCodeEntry
{
23 KeyboardCode key_code
;
24 } dom_code_to_keyboard_code
[] = {
25 // Entries are ordered by numeric value of the DomCode enum,
26 // which is the USB physical key code.
27 // DomCode::HYPER 0x000010 Hyper
28 // DomCode::SUPER 0x000011 Super
29 // DomCode::FN 0x000012 Fn
30 // DomCode::FN_LOCK 0x000013 FLock
31 // DomCode::SUSPEND 0x000014 Suspend
32 // DomCode::RESUME 0x000015 Resume
33 // DomCode::TURBO 0x000016 Turbo
34 {DomCode::SLEEP
, VKEY_SLEEP
}, // 0x010082 Sleep
35 // DomCode::WAKE_UP 0x010083 WakeUp
36 {DomCode::KEY_A
, VKEY_A
}, // 0x070004 KeyA
37 {DomCode::KEY_B
, VKEY_B
}, // 0x070005 KeyB
38 {DomCode::KEY_C
, VKEY_C
}, // 0x070006 KeyC
39 {DomCode::KEY_D
, VKEY_D
}, // 0x070007 KeyD
40 {DomCode::KEY_E
, VKEY_E
}, // 0x070008 KeyE
41 {DomCode::KEY_F
, VKEY_F
}, // 0x070009 KeyF
42 {DomCode::KEY_G
, VKEY_G
}, // 0x07000A KeyG
43 {DomCode::KEY_H
, VKEY_H
}, // 0x07000B KeyH
44 {DomCode::KEY_I
, VKEY_I
}, // 0x07000C KeyI
45 {DomCode::KEY_J
, VKEY_J
}, // 0x07000D KeyJ
46 {DomCode::KEY_K
, VKEY_K
}, // 0x07000E KeyK
47 {DomCode::KEY_L
, VKEY_L
}, // 0x07000F KeyL
48 {DomCode::KEY_M
, VKEY_M
}, // 0x070010 KeyM
49 {DomCode::KEY_N
, VKEY_N
}, // 0x070011 KeyN
50 {DomCode::KEY_O
, VKEY_O
}, // 0x070012 KeyO
51 {DomCode::KEY_P
, VKEY_P
}, // 0x070013 KeyP
52 {DomCode::KEY_Q
, VKEY_Q
}, // 0x070014 KeyQ
53 {DomCode::KEY_R
, VKEY_R
}, // 0x070015 KeyR
54 {DomCode::KEY_S
, VKEY_S
}, // 0x070016 KeyS
55 {DomCode::KEY_T
, VKEY_T
}, // 0x070017 KeyT
56 {DomCode::KEY_U
, VKEY_U
}, // 0x070018 KeyU
57 {DomCode::KEY_V
, VKEY_V
}, // 0x070019 KeyV
58 {DomCode::KEY_W
, VKEY_W
}, // 0x07001A KeyW
59 {DomCode::KEY_X
, VKEY_X
}, // 0x07001B KeyX
60 {DomCode::KEY_Y
, VKEY_Y
}, // 0x07001C KeyY
61 {DomCode::KEY_Z
, VKEY_Z
}, // 0x07001D KeyZ
62 {DomCode::DIGIT1
, VKEY_1
}, // 0x07001E Digit1
63 {DomCode::DIGIT2
, VKEY_2
}, // 0x07001F Digit2
64 {DomCode::DIGIT3
, VKEY_3
}, // 0x070020 Digit3
65 {DomCode::DIGIT4
, VKEY_4
}, // 0x070021 Digit4
66 {DomCode::DIGIT5
, VKEY_5
}, // 0x070022 Digit5
67 {DomCode::DIGIT6
, VKEY_6
}, // 0x070023 Digit6
68 {DomCode::DIGIT7
, VKEY_7
}, // 0x070024 Digit7
69 {DomCode::DIGIT8
, VKEY_8
}, // 0x070025 Digit8
70 {DomCode::DIGIT9
, VKEY_9
}, // 0x070026 Digit9
71 {DomCode::DIGIT0
, VKEY_0
}, // 0x070027 Digit0
72 {DomCode::ENTER
, VKEY_RETURN
}, // 0x070028 Enter
73 {DomCode::ESCAPE
, VKEY_ESCAPE
}, // 0x070029 Escape
74 {DomCode::BACKSPACE
, VKEY_BACK
}, // 0x07002A Backspace
75 {DomCode::TAB
, VKEY_TAB
}, // 0x07002B Tab
76 {DomCode::SPACE
, VKEY_SPACE
}, // 0x07002C Space
77 {DomCode::MINUS
, VKEY_OEM_MINUS
}, // 0x07002D Minus
78 {DomCode::EQUAL
, VKEY_OEM_PLUS
}, // 0x07002E Equal
79 {DomCode::BRACKET_LEFT
, VKEY_OEM_4
}, // 0x07002F BracketLeft
80 {DomCode::BRACKET_RIGHT
, VKEY_OEM_6
}, // 0x070030 BracketRight
81 {DomCode::BACKSLASH
, VKEY_OEM_5
}, // 0x070031 Backslash
82 // DomCode::INTL_HASH, VKEY_OEM_5 // 0x070032 IntlHash
83 {DomCode::SEMICOLON
, VKEY_OEM_1
}, // 0x070033 Semicolon
84 {DomCode::QUOTE
, VKEY_OEM_7
}, // 0x070034 Quote
85 {DomCode::BACKQUOTE
, VKEY_OEM_3
}, // 0x070035 Backquote
86 {DomCode::COMMA
, VKEY_OEM_COMMA
}, // 0x070036 Comma
87 {DomCode::PERIOD
, VKEY_OEM_PERIOD
}, // 0x070037 Period
88 {DomCode::SLASH
, VKEY_OEM_2
}, // 0x070038 Slash
89 {DomCode::CAPS_LOCK
, VKEY_CAPITAL
}, // 0x070039 CapsLock
90 {DomCode::F1
, VKEY_F1
}, // 0x07003A F1
91 {DomCode::F2
, VKEY_F2
}, // 0x07003B F2
92 {DomCode::F3
, VKEY_F3
}, // 0x07003C F3
93 {DomCode::F4
, VKEY_F4
}, // 0x07003D F4
94 {DomCode::F5
, VKEY_F5
}, // 0x07003E F5
95 {DomCode::F6
, VKEY_F6
}, // 0x07003F F6
96 {DomCode::F7
, VKEY_F7
}, // 0x070040 F7
97 {DomCode::F8
, VKEY_F8
}, // 0x070041 F8
98 {DomCode::F9
, VKEY_F9
}, // 0x070042 F9
99 {DomCode::F10
, VKEY_F10
}, // 0x070043 F10
100 {DomCode::F11
, VKEY_F11
}, // 0x070044 F11
101 {DomCode::F12
, VKEY_F12
}, // 0x070045 F12
102 {DomCode::PRINT_SCREEN
, VKEY_SNAPSHOT
}, // 0x070046 PrintScreen
103 {DomCode::SCROLL_LOCK
, VKEY_SCROLL
}, // 0x070047 ScrollLock
104 {DomCode::PAUSE
, VKEY_PAUSE
}, // 0x070048 Pause
105 {DomCode::INSERT
, VKEY_INSERT
}, // 0x070049 Insert
106 {DomCode::HOME
, VKEY_HOME
}, // 0x07004A Home
107 {DomCode::PAGE_UP
, VKEY_PRIOR
}, // 0x07004B PageUp
108 {DomCode::DEL
, VKEY_DELETE
}, // 0x07004C Delete
109 {DomCode::END
, VKEY_END
}, // 0x07004D End
110 {DomCode::PAGE_DOWN
, VKEY_NEXT
}, // 0x07004E PageDown
111 {DomCode::ARROW_RIGHT
, VKEY_RIGHT
}, // 0x07004F ArrowRight
112 {DomCode::ARROW_LEFT
, VKEY_LEFT
}, // 0x070050 ArrowLeft
113 {DomCode::ARROW_DOWN
, VKEY_DOWN
}, // 0x070051 ArrowDown
114 {DomCode::ARROW_UP
, VKEY_UP
}, // 0x070052 ArrowUp
115 {DomCode::NUM_LOCK
, VKEY_NUMLOCK
}, // 0x070053 NumLock
116 {DomCode::NUMPAD_DIVIDE
, VKEY_DIVIDE
}, // 0x070054 NumpadDivide
117 {DomCode::NUMPAD_MULTIPLY
, VKEY_MULTIPLY
}, // 0x070055 NumpadMultiply
118 {DomCode::NUMPAD_SUBTRACT
, VKEY_SUBTRACT
}, // 0x070056 NumpadSubtract
119 {DomCode::NUMPAD_ADD
, VKEY_ADD
}, // 0x070057 NumpadAdd
120 {DomCode::NUMPAD_ENTER
, VKEY_RETURN
}, // 0x070058 NumpadEnter
121 {DomCode::NUMPAD1
, VKEY_NUMPAD1
}, // 0x070059 Numpad1
122 {DomCode::NUMPAD2
, VKEY_NUMPAD2
}, // 0x07005A Numpad2
123 {DomCode::NUMPAD3
, VKEY_NUMPAD3
}, // 0x07005B Numpad3
124 {DomCode::NUMPAD4
, VKEY_NUMPAD4
}, // 0x07005C Numpad4
125 {DomCode::NUMPAD5
, VKEY_NUMPAD5
}, // 0x07005D Numpad5
126 {DomCode::NUMPAD6
, VKEY_NUMPAD6
}, // 0x07005E Numpad6
127 {DomCode::NUMPAD7
, VKEY_NUMPAD7
}, // 0x07005F Numpad7
128 {DomCode::NUMPAD8
, VKEY_NUMPAD8
}, // 0x070060 Numpad8
129 {DomCode::NUMPAD9
, VKEY_NUMPAD9
}, // 0x070061 Numpad9
130 {DomCode::NUMPAD0
, VKEY_NUMPAD0
}, // 0x070062 Numpad0
131 {DomCode::NUMPAD_DECIMAL
, VKEY_DECIMAL
}, // 0x070063 NumpadDecimal
132 {DomCode::INTL_BACKSLASH
, VKEY_OEM_102
}, // 0x070064 IntlBackslash
133 {DomCode::CONTEXT_MENU
, VKEY_APPS
}, // 0x070065 ContextMenu
134 {DomCode::POWER
, VKEY_POWER
}, // 0x070066 Power
135 // DomCode::NUMPAD_EQUAL 0x070067 NumpadEqual
136 // DomCode::OPEN 0x070074 Open
137 {DomCode::HELP
, VKEY_HELP
}, // 0x070075 Help
138 {DomCode::SELECT
, VKEY_SELECT
}, // 0x070077 Select
139 // DomCode::AGAIN 0x070079 Again
140 // DomCode::UNDO 0x07007A Undo
141 // DomCode::CUT 0x07007B Cut
142 // DomCode::COPY 0x07007C Copy
143 // DomCode::PASTE 0x07007D Paste
144 // DomCode::FIND 0x07007E Find
145 {DomCode::VOLUME_MUTE
, VKEY_VOLUME_MUTE
}, // 0x07007F VolumeMute
146 {DomCode::VOLUME_UP
, VKEY_VOLUME_UP
}, // 0x070080 VolumeUp
147 {DomCode::VOLUME_DOWN
, VKEY_VOLUME_DOWN
}, // 0x070081 VolumeDown
148 {DomCode::NUMPAD_COMMA
, VKEY_OEM_COMMA
}, // 0x070085 NumpadComma
149 {DomCode::INTL_RO
, VKEY_OEM_102
}, // 0x070087 IntlRo
150 {DomCode::KANA_MODE
, VKEY_KANA
}, // 0x070088 KanaMode
151 {DomCode::INTL_YEN
, VKEY_OEM_5
}, // 0x070089 IntlYen
152 {DomCode::CONVERT
, VKEY_CONVERT
}, // 0x07008A Convert
153 {DomCode::NON_CONVERT
, VKEY_NONCONVERT
}, // 0x07008B NonConvert
154 {DomCode::LANG1
, VKEY_KANA
}, // 0x070090 Lang1
155 {DomCode::LANG2
, VKEY_KANJI
}, // 0x070091 Lang2
156 // DomCode::LANG3 0x070092 Lang3
157 // DomCode::LANG4 0x070093 Lang4
158 // DomCode::LANG5 0x070094 Lang5
159 // DomCode::ABORT 0x07009B Abort
160 // DomCode::PROPS 0x0700A3 Props
161 // DomCode::NUMPAD_PAREN_LEFT 0x0700B6 NumpadParenLeft
162 // DomCode::NUMPAD_PAREN_RIGHT 0x0700B7 NumpadParenRight
163 {DomCode::NUMPAD_BACKSPACE
, VKEY_BACK
}, // 0x0700BB NumpadBackspace
164 // DomCode::NUMPAD_MEMORY_STORE 0x0700D0 NumpadMemoryStore
165 // DomCode::NUMPAD_MEMORY_RECALL 0x0700D1 NumpadMemoryRecall
166 // DomCode::NUMPAD_MEMORY_CLEAR 0x0700D2 NumpadMemoryClear
167 // DomCode::NUMPAD_MEMORY_ADD 0x0700D3 NumpadMemoryAdd
168 // DomCode::NUMPAD_MEMORY_SUBTRACT 0x0700D4
169 // NumpadMemorySubtract
170 {DomCode::NUMPAD_CLEAR
, VKEY_CLEAR
}, // 0x0700D8 NumpadClear
171 {DomCode::NUMPAD_CLEAR_ENTRY
, VKEY_CLEAR
}, // 0x0700D9 NumpadClearEntry
172 {DomCode::CONTROL_LEFT
, VKEY_LCONTROL
}, // 0x0700E0 ControlLeft
173 {DomCode::SHIFT_LEFT
, VKEY_LSHIFT
}, // 0x0700E1 ShiftLeft
174 {DomCode::ALT_LEFT
, VKEY_LMENU
}, // 0x0700E2 AltLeft
175 {DomCode::OS_LEFT
, VKEY_LWIN
}, // 0x0700E3 OSLeft
176 {DomCode::CONTROL_RIGHT
, VKEY_RCONTROL
}, // 0x0700E4 ControlRight
177 {DomCode::SHIFT_RIGHT
, VKEY_RSHIFT
}, // 0x0700E5 ShiftRight
178 {DomCode::ALT_RIGHT
, VKEY_RMENU
}, // 0x0700E6 AltRight
179 {DomCode::OS_RIGHT
, VKEY_RWIN
}, // 0x0700E7 OSRight
180 {DomCode::MEDIA_TRACK_NEXT
,
181 VKEY_MEDIA_NEXT_TRACK
}, // 0x0C00B5 MediaTrackNext
182 {DomCode::MEDIA_TRACK_PREVIOUS
,
183 VKEY_MEDIA_PREV_TRACK
}, // 0x0C00B6 MediaTrackPrevious
184 {DomCode::MEDIA_STOP
, VKEY_MEDIA_STOP
}, // 0x0C00B7 MediaStop
185 // DomCode::EJECT 0x0C00B8 Eject
186 {DomCode::MEDIA_PLAY_PAUSE
,
187 VKEY_MEDIA_PLAY_PAUSE
}, // 0x0C00CD MediaPlayPause
188 {DomCode::MEDIA_SELECT
,
189 VKEY_MEDIA_LAUNCH_MEDIA_SELECT
}, // 0x0C0183 MediaSelect
190 {DomCode::LAUNCH_MAIL
, VKEY_MEDIA_LAUNCH_MAIL
}, // 0x0C018A LaunchMail
191 {DomCode::LAUNCH_APP2
, VKEY_MEDIA_LAUNCH_APP2
}, // 0x0C0192 LaunchApp2
192 {DomCode::LAUNCH_APP1
, VKEY_MEDIA_LAUNCH_APP1
}, // 0x0C0194 LaunchApp1
193 {DomCode::BROWSER_SEARCH
, VKEY_BROWSER_SEARCH
}, // 0x0C0221 BrowserSearch
194 {DomCode::BROWSER_HOME
, VKEY_BROWSER_HOME
}, // 0x0C0223 BrowserHome
195 {DomCode::BROWSER_BACK
, VKEY_BROWSER_BACK
}, // 0x0C0224 BrowserBack
196 {DomCode::BROWSER_FORWARD
,
197 VKEY_BROWSER_FORWARD
}, // 0x0C0225 BrowserForward
198 {DomCode::BROWSER_STOP
, VKEY_BROWSER_STOP
}, // 0x0C0226 BrowserStop
199 {DomCode::BROWSER_REFRESH
,
200 VKEY_BROWSER_REFRESH
}, // 0x0C0227 BrowserRefresh
201 {DomCode::BROWSER_FAVORITES
,
202 VKEY_BROWSER_FAVORITES
}, // 0x0C022A BrowserFavorites
205 } // anonymous namespace
207 // Returns a Windows-based VKEY for a non-printable DOM Level 3 |key|.
208 // The returned VKEY is non-positional (e.g. VKEY_SHIFT).
209 KeyboardCode
NonPrintableDomKeyToKeyboardCode(DomKey dom_key
) {
215 // Special Key Values
216 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-special
217 case DomKey::UNIDENTIFIED
:
220 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-modifier
223 case DomKey::ALT_GRAPH
:
225 case DomKey::CAPS_LOCK
:
227 case DomKey::CONTROL
:
229 case DomKey::NUM_LOCK
:
233 case DomKey::SCROLL_LOCK
:
238 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-whitespace
241 case DomKey::SEPARATOR
:
242 return VKEY_SEPARATOR
;
246 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-navigation
247 case DomKey::ARROW_DOWN
:
249 case DomKey::ARROW_LEFT
:
251 case DomKey::ARROW_RIGHT
:
253 case DomKey::ARROW_UP
:
259 case DomKey::PAGE_DOWN
:
261 case DomKey::PAGE_UP
:
264 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-editing
265 case DomKey::BACKSPACE
:
273 case DomKey::ERASE_EOF
:
280 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-ui
285 case DomKey::CONTEXT_MENU
:
289 case DomKey::EXECUTE
:
300 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-device
301 case DomKey::BRIGHTNESS_DOWN
:
302 return VKEY_BRIGHTNESS_DOWN
;
303 case DomKey::BRIGHTNESS_UP
:
304 return VKEY_BRIGHTNESS_UP
;
307 case DomKey::PRINT_SCREEN
:
308 return VKEY_SNAPSHOT
;
309 // IME and Composition Keys
310 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-composition
311 #if 0 // TODO(kpschoedel)
312 case DomKey::COMPOSE
:
315 case DomKey::CONVERT
:
317 case DomKey::FINAL_MODE
:
319 case DomKey::MODE_CHANGE
:
320 return VKEY_MODECHANGE
;
321 case DomKey::NON_CONVERT
:
322 return VKEY_NONCONVERT
;
323 case DomKey::PROCESS
:
324 return VKEY_PROCESSKEY
;
325 // Keys specific to Korean keyboards
326 case DomKey::HANGUL_MODE
:
328 case DomKey::HANJA_MODE
:
330 case DomKey::JUNJA_MODE
:
332 // Keys specific to Japanese keyboards
333 case DomKey::HANKAKU
:
334 return VKEY_DBE_SBCSCHAR
;
335 case DomKey::KANA_MODE
:
337 case DomKey::KANJI_MODE
:
339 case DomKey::ZENKAKU
:
340 return VKEY_DBE_DBCSCHAR
;
341 case DomKey::ZENKAKU_HANKAKU
:
342 return VKEY_DBE_DBCSCHAR
;
343 // General-Purpose Function Keys
344 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-function
394 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-multimedia
395 case DomKey::MEDIA_PLAY_PAUSE
:
396 return VKEY_MEDIA_PLAY_PAUSE
;
397 case DomKey::MEDIA_SELECT
:
398 return VKEY_MEDIA_LAUNCH_MEDIA_SELECT
;
399 case DomKey::MEDIA_STOP
:
400 return VKEY_MEDIA_STOP
;
401 case DomKey::MEDIA_TRACK_NEXT
:
402 return VKEY_MEDIA_NEXT_TRACK
;
403 case DomKey::MEDIA_TRACK_PREVIOUS
:
404 return VKEY_MEDIA_PREV_TRACK
;
407 case DomKey::VOLUME_DOWN
:
408 return VKEY_VOLUME_DOWN
;
409 case DomKey::VOLUME_MUTE
:
410 return VKEY_VOLUME_MUTE
;
411 case DomKey::VOLUME_UP
:
412 return VKEY_VOLUME_UP
;
414 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-apps
415 case DomKey::LAUNCH_CALCULATOR
:
416 return VKEY_MEDIA_LAUNCH_APP2
;
417 case DomKey::LAUNCH_MAIL
:
418 return VKEY_MEDIA_LAUNCH_MAIL
;
419 case DomKey::LAUNCH_MY_COMPUTER
:
420 return VKEY_MEDIA_LAUNCH_APP1
;
422 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-browser
423 case DomKey::BROWSER_BACK
:
424 return VKEY_BROWSER_BACK
;
425 case DomKey::BROWSER_FAVORITES
:
426 return VKEY_BROWSER_FAVORITES
;
427 case DomKey::BROWSER_FORWARD
:
428 return VKEY_BROWSER_FORWARD
;
429 case DomKey::BROWSER_HOME
:
430 return VKEY_BROWSER_HOME
;
431 case DomKey::BROWSER_REFRESH
:
432 return VKEY_BROWSER_REFRESH
;
433 case DomKey::BROWSER_SEARCH
:
434 return VKEY_BROWSER_SEARCH
;
435 case DomKey::BROWSER_STOP
:
436 return VKEY_BROWSER_STOP
;
437 // Media Controller Keys
438 // http://www.w3.org/TR/DOM-Level-3-Events-key/#keys-media-controller
439 case DomKey::ZOOM_TOGGLE
:
447 // Returns the Windows-based VKEY value corresponding to a DOM Level 3 |code|.
448 // The returned VKEY is located (e.g. VKEY_LSHIFT).
449 KeyboardCode
DomCodeToKeyboardCode(DomCode dom_code
) {
450 const DomCodeToKeyboardCodeEntry
* end
=
451 dom_code_to_keyboard_code
+ arraysize(dom_code_to_keyboard_code
);
452 const DomCodeToKeyboardCodeEntry
* found
=
453 std::lower_bound(dom_code_to_keyboard_code
, end
, dom_code
,
454 [](const DomCodeToKeyboardCodeEntry
& a
, DomCode b
) {
455 return static_cast<int>(a
.dom_code
) < static_cast<int>(b
);
457 if ((found
!= end
) && (found
->dom_code
== dom_code
))
458 return found
->key_code
;
462 // Returns the Windows-based VKEY value corresponding to a DOM Level 3 |code|.
463 // The returned VKEY is non-located (e.g. VKEY_SHIFT).
464 KeyboardCode
DomCodeToNonLocatedKeyboardCode(DomCode dom_code
) {
465 return LocatedToNonLocatedKeyboardCode(DomCodeToKeyboardCode(dom_code
));
468 bool LookupControlCharacter(DomCode dom_code
,
471 base::char16
* character
,
472 KeyboardCode
* key_code
) {
473 if ((flags
& EF_CONTROL_DOWN
) == 0)
476 int code
= static_cast<int>(dom_code
);
477 const int kKeyA
= static_cast<int>(DomCode::KEY_A
);
478 // Control-A - Control-Z map to 0x01 - 0x1A.
479 if (code
>= kKeyA
&& code
<= static_cast<int>(DomCode::KEY_Z
)) {
480 *character
= static_cast<base::char16
>(code
- kKeyA
+ 1);
481 *key_code
= static_cast<KeyboardCode
>(code
- kKeyA
+ VKEY_A
);
484 *dom_key
= DomKey::BACKSPACE
;
486 *dom_key
= DomKey::TAB
;
488 *dom_key
= DomKey::ENTER
;
490 *dom_key
= DomKey::CHARACTER
;
496 case DomCode::DIGIT2
:
499 *dom_key
= DomKey::CHARACTER
;
505 *dom_key
= DomKey::CHARACTER
;
506 *key_code
= VKEY_RETURN
;
508 case DomCode::BRACKET_LEFT
:
511 *dom_key
= DomKey::ESCAPE
;
512 *key_code
= VKEY_OEM_4
;
514 case DomCode::BACKSLASH
:
517 *dom_key
= DomKey::CHARACTER
;
518 *key_code
= VKEY_OEM_5
;
520 case DomCode::BRACKET_RIGHT
:
523 *dom_key
= DomKey::CHARACTER
;
524 *key_code
= VKEY_OEM_6
;
526 case DomCode::DIGIT6
:
529 *dom_key
= DomKey::CHARACTER
;
535 *dom_key
= DomKey::CHARACTER
;
536 *key_code
= VKEY_OEM_MINUS
;
543 int ModifierDomKeyToEventFlag(DomKey key
) {
547 case DomKey::ALT_GRAPH
:
548 return EF_ALTGR_DOWN
;
549 // ChromeOS uses F16 to represent CapsLock before the rewriting stage,
550 // based on the historical X11 implementation.
551 // TODO post-X11: Switch to use CapsLock uniformly.
553 case DomKey::CAPS_LOCK
:
554 return EF_CAPS_LOCK_DOWN
;
555 case DomKey::CONTROL
:
556 return EF_CONTROL_DOWN
;
562 return EF_COMMAND_DOWN
;
564 return EF_SHIFT_DOWN
;
575 // DomKey::SCROLL_LOCK
577 // DomKey::SYMBOL_LOCK