Merge mozilla-central to autoland on a CLOSED TREE
[gecko.git] / dom / events / ShortcutKeyDefinitions.cpp
blob3f34f4524044498bee966bc5b72eec88f7b39ed5
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "ShortcutKeys.h"
7 #if !defined(XP_WIN) && !defined(MOZ_WIDGET_COCOA) && \
8 !defined(MOZ_WIDGET_GTK) && !defined(MOZ_WIDGET_ANDROID)
9 # define USE_EMACS_KEY_BINDINGS
10 #endif
12 /**
13 * This file defines shortcut keys for <input>, <textarea>, page navigation
14 * and HTML editor. You must write each mapping in one line and append inline
15 * comment on which platform it's mapped since this style helps you to looking
16 * for the defintion with searchfox, etc.
17 * Be aware, the commands defined in this file may not work because editor or
18 * other keyboard event listeners may handle before.
19 * Note: When you change key mappings, you need to change
20 * `test/gtest/TestShortcutKeyDefinitions.cpp` too.
22 * The latest version of the original files are:
24 * Windows:
25 * https://searchfox.org/mozilla-central/rev/fd853f4aea89186efdb368e759a71b7a90c2b89c/dom/events/win/ShortcutKeyDefinitions.cpp
26 * macOS:
27 * https://searchfox.org/mozilla-central/rev/fd853f4aea89186efdb368e759a71b7a90c2b89c/dom/events/mac/ShortcutKeyDefinitions.cpp
28 * Linux:
29 * https://searchfox.org/mozilla-central/rev/fd853f4aea89186efdb368e759a71b7a90c2b89c/dom/events/unix/ShortcutKeyDefinitions.cpp
30 * Android:
31 * https://searchfox.org/mozilla-central/rev/fd853f4aea89186efdb368e759a71b7a90c2b89c/dom/events/android/ShortcutKeyDefinitions.cpp
32 * Emacs:
33 * https://searchfox.org/mozilla-central/rev/fd853f4aea89186efdb368e759a71b7a90c2b89c/dom/events/emacs/ShortcutKeyDefinitions.cpp
35 * And common definitions except macOS:
36 * https://searchfox.org/mozilla-central/rev/fd853f4aea89186efdb368e759a71b7a90c2b89c/dom/events/ShortcutKeyDefinitionsForInputCommon.h
37 * https://searchfox.org/mozilla-central/rev/fd853f4aea89186efdb368e759a71b7a90c2b89c/dom/events/ShortcutKeyDefinitionsForTextAreaCommon.h
38 * https://searchfox.org/mozilla-central/rev/fd853f4aea89186efdb368e759a71b7a90c2b89c/dom/events/ShortcutKeyDefinitionsForEditorCommon.h
40 * And common definitions for page navigation on all platforms:
41 * https://searchfox.org/mozilla-central/rev/fd853f4aea89186efdb368e759a71b7a90c2b89c/dom/events/ShortcutKeyDefinitionsForBrowserCommon.h
43 * If you don't see shortcut key definitions here, but you see shortcut keys
44 * work on Linux or macOS, it probably comes from NativeKeyBindings under
45 * widget.
48 namespace mozilla {
50 ShortcutKeyData ShortcutKeys::sInputHandlers[] = {
51 // clang-format off
52 /**************************************************************************
53 * Arrow keys to move caret in <input>.
54 **************************************************************************/
55 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || \
56 defined(MOZ_WIDGET_ANDROID) || defined(USE_EMACS_KEY_BINDINGS)
57 {u"keypress", u"VK_LEFT", nullptr, nullptr, u"cmd_moveLeft"}, // Win, Linux, Android, Emacs
58 {u"keypress", u"VK_RIGHT", nullptr, nullptr, u"cmd_moveRight"}, // Win, Linux, Android, Emacs
59 {u"keypress", u"VK_UP", nullptr, nullptr, u"cmd_moveUp"}, // Win, Linux, Android, Emacs
60 {u"keypress", u"VK_DOWN", nullptr, nullptr, u"cmd_moveDown"}, // Win, Linux, Android, Emacs
61 #endif // Except MOZ_WIDGET_COCOA
63 /**************************************************************************
64 * Arrow keys to select a char/line in <input>.
65 **************************************************************************/
66 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || \
67 defined(MOZ_WIDGET_ANDROID) || defined(USE_EMACS_KEY_BINDINGS)
68 {u"keypress", u"VK_LEFT", nullptr, u"shift", u"cmd_selectLeft"}, // Win, Linux, Android, Emacs
69 {u"keypress", u"VK_RIGHT", nullptr, u"shift", u"cmd_selectRight"}, // Win, Linux, Android, Emacs
70 {u"keypress", u"VK_UP", nullptr, u"shift", u"cmd_selectUp"}, // Win, Linux, Android, Emacs
71 {u"keypress", u"VK_DOWN", nullptr, u"shift", u"cmd_selectDown"}, // Win, Linux, Android, Emacs
72 #endif // Except MOZ_WIDGET_COCOA
74 /**************************************************************************
75 * Arrow keys per word in <input>.
76 **************************************************************************/
77 #if defined(MOZ_WIDGET_ANDROID) || defined(USE_EMACS_KEY_BINDINGS)
78 {u"keypress", u"VK_LEFT", nullptr, u"control", u"cmd_wordPrevious"}, // Android, Emacs
79 {u"keypress", u"VK_RIGHT", nullptr, u"control", u"cmd_wordNext"}, // Android, Emacs
80 {u"keypress", u"VK_LEFT", nullptr, u"shift,control", u"cmd_selectWordPrevious"}, // Android, Emacs
81 {u"keypress", u"VK_RIGHT", nullptr, u"shift,control", u"cmd_selectWordNext"}, // Android, Emacs
82 #endif // MOZ_WIDGET_ANDROID || USE_EMACS_KEY_BINDINGS
83 #if defined(XP_WIN)
84 {u"keypress", u"VK_LEFT", nullptr, u"control", u"cmd_moveLeft2"}, // Win
85 {u"keypress", u"VK_RIGHT", nullptr, u"control", u"cmd_moveRight2"}, // Win
86 {u"keypress", u"VK_LEFT", nullptr, u"shift,control", u"cmd_selectLeft2"}, // Win
87 {u"keypress", u"VK_RIGHT", nullptr, u"shift,control", u"cmd_selectRight2"}, // Win
88 #endif // XP_WIN
90 /**************************************************************************
91 * Arrow keys per block in <input>.
92 **************************************************************************/
93 #if defined(XP_WIN)
94 {u"keypress", u"VK_UP", nullptr, u"control", u"cmd_moveUp2"}, // Win
95 {u"keypress", u"VK_DOWN", nullptr, u"control", u"cmd_moveDown2"}, // Win
96 {u"keypress", u"VK_UP", nullptr, u"shift,control", u"cmd_selectUp2"}, // Win
97 {u"keypress", u"VK_DOWN", nullptr, u"shift,control", u"cmd_selectDown2"}, // Win
98 #endif // XP_WIN
100 /**************************************************************************
101 * Arrow keys to begin/end of a line in <input>.
102 **************************************************************************/
103 #if defined(MOZ_WIDGET_ANDROID)
104 {u"keypress", u"VK_LEFT", nullptr, u"alt", u"cmd_beginLine"}, // Android
105 {u"keypress", u"VK_RIGHT", nullptr, u"alt", u"cmd_endLine"}, // Android
106 {u"keypress", u"VK_LEFT", nullptr, u"shift,alt", u"cmd_selectBeginLine"}, // Android
107 {u"keypress", u"VK_RIGHT", nullptr, u"shift,alt", u"cmd_selectEndLine"}, // Android
108 #endif // MOZ_WIDGET_ANDROID
110 /**************************************************************************
111 * Home/End keys in <input>.
112 **************************************************************************/
113 #if defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID) ||\
114 defined(USE_EMACS_KEY_BINDINGS)
115 {u"keypress", u"VK_HOME", nullptr, nullptr, u"cmd_beginLine"}, // Win, Android, Emacs
116 {u"keypress", u"VK_END", nullptr, nullptr, u"cmd_endLine"}, // Win, Android, Emacs
117 {u"keypress", u"VK_HOME", nullptr, u"shift", u"cmd_selectBeginLine"}, // Win, Android, Emacs
118 {u"keypress", u"VK_END", nullptr, u"shift", u"cmd_selectEndLine"}, // Win, Android, Emacs
119 #endif // XP_WIN || MOZ_WIDGET_ANDROID || USE_EMACS_KEY_BINDINGS
120 #if defined(USE_EMACS_KEY_BINDINGS)
121 {u"keypress", u"VK_HOME", nullptr, u"control", u"cmd_beginLine"}, // Emacs
122 {u"keypress", u"VK_END", nullptr, u"control", u"cmd_endLine"}, // Emacs
123 {u"keypress", u"VK_HOME", nullptr, u"control,shift", u"cmd_selectBeginLine"}, // Emacs
124 {u"keypress", u"VK_END", nullptr, u"control,shift", u"cmd_selectEndLine"}, // Emacs
125 #endif // USE_EMACS_KEY_BINDINGS
126 #if defined(XP_WIN)
127 {u"keypress", u"VK_HOME", nullptr, u"control", u"cmd_moveTop"}, // Win
128 {u"keypress", u"VK_END", nullptr, u"control", u"cmd_moveBottom"}, // Win
129 {u"keypress", u"VK_HOME", nullptr, u"shift,control", u"cmd_selectTop"}, // Win
130 {u"keypress", u"VK_END", nullptr, u"shift,control", u"cmd_selectBottom"}, // Win
131 #endif // XP_WIN
133 /**************************************************************************
134 * Insert key in <input>.
135 **************************************************************************/
136 #if defined(XP_WIN) || defined(USE_EMACS_KEY_BINDINGS)
137 {u"keypress", u"VK_INSERT", nullptr, u"control", u"cmd_copy"}, // Win, Emacs
138 {u"keypress", u"VK_INSERT", nullptr, u"shift", u"cmd_paste"}, // Win, Emacs
139 #endif // XP_WIN || USE_EMACS_KEY_BINDINGS
141 /**************************************************************************
142 * Delete key in <input>.
143 **************************************************************************/
144 #if defined(XP_WIN) || defined(USE_EMACS_KEY_BINDINGS)
145 {u"keypress", u"VK_DELETE", nullptr, u"shift", u"cmd_cutOrDelete"}, // Win, Emacs
146 #endif // XP_WIN || USE_EMACS_KEY_BINDINGS
147 #if defined(USE_EMACS_KEY_BINDINGS)
148 {u"keypress", u"VK_DELETE", nullptr, u"control", u"cmd_copyOrDelete"}, // Emacs
149 #endif // USE_EMACS_KEY_BINDINGS
150 #if defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID)
151 {u"keypress", u"VK_DELETE", nullptr, u"control", u"cmd_deleteWordForward"}, // Win, Android
152 #endif // XP_WIN
153 #if defined(MOZ_WIDGET_ANDROID)
154 {u"keypress", u"VK_DELETE", nullptr, u"alt", u"cmd_deleteToEndOfLine"}, // Android
155 #endif // MOZ_WIDGET_ANDROID
157 /**************************************************************************
158 * Backspace key in <input>.
159 **************************************************************************/
160 #if defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID) ||\
161 defined(USE_EMACS_KEY_BINDINGS)
162 {u"keypress", u"VK_BACK", nullptr, u"control", u"cmd_deleteWordBackward"}, // Win, Android, Emacs
163 #endif // XP_WIN || MOZ_WIDGET_ANDROID || USE_EMACS_KEY_BINDINGS
164 #if defined(MOZ_WIDGET_ANDROID)
165 {u"keypress", u"VK_BACK", nullptr, u"alt", u"cmd_deleteToBeginningOfLine"}, // Android
166 #endif // MOZ_WIDGET_ANDROID
167 #if defined(XP_WIN)
168 {u"keypress", u"VK_BACK", nullptr, u"alt", u"cmd_undo"}, // Win
169 {u"keypress", u"VK_BACK", nullptr, u"alt,shift", u"cmd_redo"}, // Win
170 #endif // XP_WIN
172 /**************************************************************************
173 * Common editor commands in <input>.
174 **************************************************************************/
175 {u"keypress", nullptr, u"c", u"accel", u"cmd_copy"}, // Win, macOS, Linux, Android, Emacs
176 {u"keypress", nullptr, u"x", u"accel", u"cmd_cut"}, // Win, macOS, Linux, Android, Emacs
177 {u"keypress", nullptr, u"v", u"accel", u"cmd_paste"}, // Win, macOS, Linux, Android, Emacs
178 {u"keypress", nullptr, u"z", u"accel", u"cmd_undo"}, // Win, macOS, Linux, Android, Emacs
179 {u"keypress", nullptr, u"z", u"accel,shift", u"cmd_redo"}, // Win, macOS, Linux, Android, Emacs
181 {u"keypress", nullptr, u"v", u"accel,shift", u"cmd_paste"}, // Win, macOS, Linux, Android, Emacs
182 // Mac uses Option+Shift+Command+V for Paste and Match Style
183 #if defined(MOZ_WIDGET_COCOA)
184 {u"keypress", nullptr, u"v", u"accel,alt,shift", u"cmd_paste"}, // macOS
185 #endif // MOZ_WIDGET_COCOA
187 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) ||\
188 defined(USE_EMACS_KEY_BINDINGS)
189 {u"keypress", nullptr, u"y", u"accel", u"cmd_redo"}, // Win, Linux, Emacs
190 #endif // XP_WIN || MOZ_WIDGET_GTK || USE_EMACS_KEY_BINDINGS
192 #if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_GTK) ||\
193 defined(MOZ_WIDGET_ANDROID)
194 {u"keypress", nullptr, u"a", u"accel", u"cmd_selectAll"}, // Win, macOS, Linux, Android
195 #endif // XP_WIN || MOZ_WIDGET_COCOA || MOZ_WIDGET_GTK || MOZ_WIDGET_ANDROID
196 #if defined(USE_EMACS_KEY_BINDINGS)
197 {u"keypress", nullptr, u"a", u"alt", u"cmd_selectAll"}, // Emacs
198 #endif // USE_EMACS_KEY_BINDINGS
200 /**************************************************************************
201 * Emacs specific shortcut keys in <input>.
202 **************************************************************************/
203 #if defined(USE_EMACS_KEY_BINDINGS)
204 {u"keypress", nullptr, u"a", u"control", u"cmd_beginLine"}, // Emacs
205 {u"keypress", nullptr, u"e", u"control", u"cmd_endLine"}, // Emacs
206 {u"keypress", nullptr, u"b", u"control", u"cmd_charPrevious"}, // Emacs
207 {u"keypress", nullptr, u"f", u"control", u"cmd_charNext"}, // Emacs
208 {u"keypress", nullptr, u"h", u"control", u"cmd_deleteCharBackward"}, // Emacs
209 {u"keypress", nullptr, u"d", u"control", u"cmd_deleteCharForward"}, // Emacs
210 {u"keypress", nullptr, u"w", u"control", u"cmd_deleteWordBackward"}, // Emacs
211 {u"keypress", nullptr, u"u", u"control", u"cmd_deleteToBeginningOfLine"}, // Emacs
212 {u"keypress", nullptr, u"k", u"control", u"cmd_deleteToEndOfLine"}, // Emacs
213 #endif // USE_EMACS_KEY_BINDINGS
214 // clang-format on
216 {nullptr, nullptr, nullptr, nullptr, nullptr}};
218 ShortcutKeyData ShortcutKeys::sTextAreaHandlers[] = {
219 // clang-format off
220 /**************************************************************************
221 * Arrow keys to move caret in <textarea>.
222 **************************************************************************/
223 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || \
224 defined(MOZ_WIDGET_ANDROID) || defined(USE_EMACS_KEY_BINDINGS)
225 {u"keypress", u"VK_LEFT", nullptr, nullptr, u"cmd_moveLeft"}, // Win, Linux, Android, Emacs
226 {u"keypress", u"VK_RIGHT", nullptr, nullptr, u"cmd_moveRight"}, // Win, Linux, Android, Emacs
227 {u"keypress", u"VK_UP", nullptr, nullptr, u"cmd_moveUp"}, // Win, Linux, Android, Emacs
228 {u"keypress", u"VK_DOWN", nullptr, nullptr, u"cmd_moveDown"}, // Win, Linux, Android, Emacs
229 #endif // Except MOZ_WIDGET_COCOA
231 /**************************************************************************
232 * Arrow keys to select a char/line in <textarea>.
233 **************************************************************************/
234 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || \
235 defined(MOZ_WIDGET_ANDROID) || defined(USE_EMACS_KEY_BINDINGS)
236 {u"keypress", u"VK_LEFT", nullptr, u"shift", u"cmd_selectLeft"}, // Win, Linux, Android, Emacs
237 {u"keypress", u"VK_RIGHT", nullptr, u"shift", u"cmd_selectRight"}, // Win, Linux, Android, Emacs
238 {u"keypress", u"VK_UP", nullptr, u"shift", u"cmd_selectUp"}, // Win, Linux, Android, Emacs
239 {u"keypress", u"VK_DOWN", nullptr, u"shift", u"cmd_selectDown"}, // Win, Linux, Android, Emacs
240 #endif // Except MOZ_WIDGET_COCOA
242 /**************************************************************************
243 * Arrow keys per word in <textarea>.
244 **************************************************************************/
245 #if defined(MOZ_WIDGET_ANDROID) || defined(USE_EMACS_KEY_BINDINGS)
246 {u"keypress", u"VK_LEFT", nullptr, u"control", u"cmd_wordPrevious"}, // Android, Emacs
247 {u"keypress", u"VK_RIGHT", nullptr, u"control", u"cmd_wordNext"}, // Android, Emacs
248 {u"keypress", u"VK_LEFT", nullptr, u"shift,control", u"cmd_selectWordPrevious"}, // Android, Emacs
249 {u"keypress", u"VK_RIGHT", nullptr, u"shift,control", u"cmd_selectWordNext"}, // Android, Emacs
250 #endif // MOZ_WIDGET_ANDROID || USE_EMACS_KEY_BINDINGS
251 #if defined(XP_WIN)
252 {u"keypress", u"VK_LEFT", nullptr, u"control", u"cmd_moveLeft2"}, // Win
253 {u"keypress", u"VK_RIGHT", nullptr, u"control", u"cmd_moveRight2"}, // Win
254 {u"keypress", u"VK_LEFT", nullptr, u"shift,control", u"cmd_selectLeft2"}, // Win
255 {u"keypress", u"VK_RIGHT", nullptr, u"shift,control", u"cmd_selectRight2"}, // Win
256 #endif // XP_WIN
258 /**************************************************************************
259 * Arrow keys per block in <textarea>.
260 **************************************************************************/
261 #if defined(MOZ_WIDGET_ANDROID)
262 {u"keypress", u"VK_UP", nullptr, u"alt", u"cmd_moveTop"}, // Android
263 {u"keypress", u"VK_DOWN", nullptr, u"alt", u"cmd_moveBottom"}, // Android
264 {u"keypress", u"VK_UP", nullptr, u"shift,alt", u"cmd_selectTop"}, // Android
265 {u"keypress", u"VK_DOWN", nullptr, u"shift,alt", u"cmd_selectBottom"}, // Android
266 #endif // MOZ_WIDGET_ANDROID
267 #if defined(XP_WIN)
268 {u"keypress", u"VK_UP", nullptr, u"control", u"cmd_moveUp2"}, // Win
269 {u"keypress", u"VK_DOWN", nullptr, u"control", u"cmd_moveDown2"}, // Win
270 {u"keypress", u"VK_UP", nullptr, u"shift,control", u"cmd_selectUp2"}, // Win
271 {u"keypress", u"VK_DOWN", nullptr, u"shift,control", u"cmd_selectDown2"}, // Win
272 #endif // XP_WIN
274 /**************************************************************************
275 * Arrow keys to begin/end of a line in <textarea>.
276 **************************************************************************/
277 #if defined(MOZ_WIDGET_ANDROID)
278 {u"keypress", u"VK_LEFT", nullptr, u"alt", u"cmd_beginLine"}, // Android
279 {u"keypress", u"VK_RIGHT", nullptr, u"alt", u"cmd_endLine"}, // Android
280 {u"keypress", u"VK_LEFT", nullptr, u"shift,alt", u"cmd_selectBeginLine"}, // Android
281 {u"keypress", u"VK_RIGHT", nullptr, u"shift,alt", u"cmd_selectEndLine"}, // Android
282 #endif // MOZ_WIDGET_ANDROID
284 /**************************************************************************
285 * PageUp/PageDown keys in <textarea>.
286 **************************************************************************/
287 #if defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID) ||\
288 defined(USE_EMACS_KEY_BINDINGS)
289 {u"keypress", u"VK_PAGE_UP", nullptr, nullptr, u"cmd_movePageUp"}, // Win, Android, Emacs
290 {u"keypress", u"VK_PAGE_DOWN", nullptr, nullptr, u"cmd_movePageDown"}, // Win, Android, Emacs
291 {u"keypress", u"VK_PAGE_UP", nullptr, u"shift", u"cmd_selectPageUp"}, // Win, Android, Emacs
292 {u"keypress", u"VK_PAGE_DOWN", nullptr, u"shift", u"cmd_selectPageDown"}, // Win, Android, Emacs
293 #endif // XP_WIN || MOZ_WIDGET_ANDROID || USE_EMACS_KEY_BINDINGS
294 #if defined(MOZ_WIDGET_ANDROID)
295 {u"keypress", u"VK_PAGE_UP", nullptr, u"alt", u"cmd_moveTop"}, // Android
296 {u"keypress", u"VK_PAGE_DOWN", nullptr, u"alt", u"cmd_moveBottom"}, // Android
297 {u"keypress", u"VK_PAGE_UP", nullptr, u"shift,alt", u"cmd_selectTop"}, // Android
298 {u"keypress", u"VK_PAGE_DOWN", nullptr, u"shift,alt", u"cmd_selectBottom"}, // Android
299 #endif // MOZ_WIDGET_ANDROID
301 /**************************************************************************
302 * Home/End keys in <textarea>.
303 **************************************************************************/
304 #if defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID) ||\
305 defined(USE_EMACS_KEY_BINDINGS)
306 {u"keypress", u"VK_HOME", nullptr, nullptr, u"cmd_beginLine"}, // Win, Android, Emacs
307 {u"keypress", u"VK_END", nullptr, nullptr, u"cmd_endLine"}, // Win, Android, Emacs
308 {u"keypress", u"VK_HOME", nullptr, u"shift", u"cmd_selectBeginLine"}, // Win, Android, Emacs
309 {u"keypress", u"VK_END", nullptr, u"shift", u"cmd_selectEndLine"}, // Win, Android, Emacs
310 {u"keypress", u"VK_HOME", nullptr, u"control", u"cmd_moveTop"}, // Win, Android, Emacs
311 {u"keypress", u"VK_END", nullptr, u"control", u"cmd_moveBottom"}, // Win, Android, Emacs
312 {u"keypress", u"VK_HOME", nullptr, u"shift,control", u"cmd_selectTop"}, // Win, Android, Emacs
313 {u"keypress", u"VK_END", nullptr, u"shift,control", u"cmd_selectBottom"}, // Win, Android, Emacs
314 #endif // XP_WIN || MOZ_WIDGET_ANDROID || USE_EMACS_KEY_BINDINGS
316 /**************************************************************************
317 * Insert key in <textarea>.
318 **************************************************************************/
319 #if defined(XP_WIN) || defined(USE_EMACS_KEY_BINDINGS)
320 {u"keypress", u"VK_INSERT", nullptr, u"control", u"cmd_copy"}, // Win, Emacs
321 {u"keypress", u"VK_INSERT", nullptr, u"shift", u"cmd_paste"}, // Win, Emacs
322 #endif // XP_WIN || USE_EMACS_KEY_BINDINGS
324 {u"keypress", nullptr, u"v", u"accel,shift", u"cmd_paste"}, // Win, macOS, Linux, Android, Emacs
325 // Mac uses Option+Shift+Command+V for Paste and Match Style
326 #if defined(MOZ_WIDGET_COCOA)
327 {u"keypress", nullptr, u"v", u"accel,alt,shift", u"cmd_paste"}, // macOS
328 #endif // MOZ_WIDGET_COCOA
330 /**************************************************************************
331 * Delete key in <textarea>.
332 **************************************************************************/
333 #if defined(XP_WIN) || defined(USE_EMACS_KEY_BINDINGS)
334 {u"keypress", u"VK_DELETE", nullptr, u"shift", u"cmd_cutOrDelete"}, // Win, Emacs
335 #endif // XP_WIN || USE_EMACS_KEY_BINDINGS
336 #if defined(USE_EMACS_KEY_BINDINGS)
337 {u"keypress", u"VK_DELETE", nullptr, u"control", u"cmd_copyOrDelete"}, // Emacs
338 #endif // USE_EMACS_KEY_BINDINGS
339 #if defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID)
340 {u"keypress", u"VK_DELETE", nullptr, u"control", u"cmd_deleteWordForward"}, // Win, Android
341 #endif // XP_WIN || MOZ_WIDGET_ANDROID
342 #if defined(MOZ_WIDGET_ANDROID)
343 {u"keypress", u"VK_DELETE", nullptr, u"alt", u"cmd_deleteToEndOfLine"}, // Android
344 #endif // MOZ_WIDGET_ANDROID
346 /**************************************************************************
347 * Backspace key in <textarea>.
348 **************************************************************************/
349 #if defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID) ||\
350 defined(USE_EMACS_KEY_BINDINGS)
351 {u"keypress", u"VK_BACK", nullptr, u"control", u"cmd_deleteWordBackward"}, // Win, Android, Emacs
352 #endif // XP_WIN || MOZ_WIDGET_ANDROID || USE_EMACS_KEY_BINDINGS
353 #if defined(MOZ_WIDGET_ANDROID)
354 {u"keypress", u"VK_BACK", nullptr, u"alt", u"cmd_deleteToBeginningOfLine"}, // Android
355 #endif // MOZ_WIDGET_ANDROID
356 #if defined(XP_WIN)
357 {u"keypress", u"VK_BACK", nullptr, u"alt", u"cmd_undo"}, // Win
358 {u"keypress", u"VK_BACK", nullptr, u"alt,shift", u"cmd_redo"}, // Win
359 #endif // XP_WIN
361 /**************************************************************************
362 * Common editor commands in <textarea>.
363 **************************************************************************/
364 {u"keypress", nullptr, u"c", u"accel", u"cmd_copy"}, // Win, macOS, Linux, Android, Emacs
365 {u"keypress", nullptr, u"x", u"accel", u"cmd_cut"}, // Win, macOS, Linux, Android, Emacs
366 {u"keypress", nullptr, u"v", u"accel", u"cmd_paste"}, // Win, macOS, Linux, Android, Emacs
367 {u"keypress", nullptr, u"z", u"accel", u"cmd_undo"}, // Win, macOS, Linux, Android, Emacs
368 {u"keypress", nullptr, u"z", u"accel,shift", u"cmd_redo"}, // Win, macOS, Linux, Android, Emacs
370 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) ||\
371 defined(USE_EMACS_KEY_BINDINGS)
372 {u"keypress", nullptr, u"y", u"accel", u"cmd_redo"}, // Win, Linux, Emacs
373 #endif // XP_WIN || MOZ_WIDGET_GTK || USE_EMACS_KEY_BINDINGS
375 #if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_GTK) ||\
376 defined(MOZ_WIDGET_ANDROID)
377 {u"keypress", nullptr, u"a", u"accel", u"cmd_selectAll"}, // Win, macOS, Linux, Android
378 #endif // XP_WIN || MOZ_WIDGET_COCOA || MOZ_WIDGET_GTK || MOZ_WIDGET_ANDROID
379 #if defined(USE_EMACS_KEY_BINDINGS)
380 {u"keypress", nullptr, u"a", u"alt", u"cmd_selectAll"}, // Emacs
381 #endif // USE_EMACS_KEY_BINDINGS
383 /**************************************************************************
384 * Emacs specific shortcut keys in <textarea>.
385 **************************************************************************/
386 #if defined(USE_EMACS_KEY_BINDINGS)
387 {u"keypress", nullptr, u"a", u"control", u"cmd_beginLine"}, // Emacs
388 {u"keypress", nullptr, u"e", u"control", u"cmd_endLine"}, // Emacs
389 {u"keypress", nullptr, u"b", u"control", u"cmd_charPrevious"}, // Emacs
390 {u"keypress", nullptr, u"f", u"control", u"cmd_charNext"}, // Emacs
391 {u"keypress", nullptr, u"h", u"control", u"cmd_deleteCharBackward"}, // Emacs
392 {u"keypress", nullptr, u"d", u"control", u"cmd_deleteCharForward"}, // Emacs
393 {u"keypress", nullptr, u"w", u"control", u"cmd_deleteWordBackward"}, // Emacs
394 {u"keypress", nullptr, u"u", u"control", u"cmd_deleteToBeginningOfLine"}, // Emacs
395 {u"keypress", nullptr, u"k", u"control", u"cmd_deleteToEndOfLine"}, // Emacs
396 {u"keypress", nullptr, u"n", u"control", u"cmd_lineNext"}, // Emacs
397 {u"keypress", nullptr, u"p", u"control", u"cmd_linePrevious"}, // Emacs
398 #endif // USE_EMACS_KEY_BINDINGS
399 // clang-format on
401 {nullptr, nullptr, nullptr, nullptr, nullptr}};
403 ShortcutKeyData ShortcutKeys::sBrowserHandlers[] = {
404 // clang-format off
405 /**************************************************************************
406 * Arrow keys to move caret in non-editable element.
407 **************************************************************************/
408 {u"keypress", u"VK_LEFT", nullptr, nullptr, u"cmd_moveLeft"}, // Win, macOS, Linux, Android, Emacs
409 {u"keypress", u"VK_RIGHT", nullptr, nullptr, u"cmd_moveRight"}, // Win, macOS, Linux, Android, Emacs
410 {u"keypress", u"VK_UP", nullptr, nullptr, u"cmd_moveUp"}, // Win, macOS, Linux, Android, Emacs
411 {u"keypress", u"VK_DOWN", nullptr, nullptr, u"cmd_moveDown"}, // Win, macOS, Linux, Android, Emacs
413 /**************************************************************************
414 * Arrow keys to select a char/line in non-editable element.
415 **************************************************************************/
416 #if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_GTK)
417 {u"keypress", u"VK_LEFT", nullptr, u"shift", u"cmd_selectLeft"}, // Win, macOS, Linux
418 {u"keypress", u"VK_RIGHT", nullptr, u"shift", u"cmd_selectRight"}, // Win, macOS, Linux
419 {u"keypress", u"VK_UP", nullptr, u"shift", u"cmd_selectUp"}, // Win, macOS, Linux
420 {u"keypress", u"VK_DOWN", nullptr, u"shift", u"cmd_selectDown"}, // Win, macOS, Linux
421 #endif // XP_WIN || MOZ_WIDGET_COCOA || MOZ_WIDGET_GTK
422 #if defined(MOZ_WIDGET_ANDROID) || defined(USE_EMACS_KEY_BINDINGS)
423 {u"keypress", u"VK_LEFT", nullptr, u"shift", u"cmd_selectCharPrevious"}, // Android, Emacs
424 {u"keypress", u"VK_RIGHT", nullptr, u"shift", u"cmd_selectCharNext"}, // Android, Emacs
425 {u"keypress", u"VK_UP", nullptr, u"shift", u"cmd_selectLinePrevious"}, // Android, Emacs
426 {u"keypress", u"VK_DOWN", nullptr, u"shift", u"cmd_selectLineNext"}, // Android, Emacs
427 #endif // MOZ_WIDGET_ANDROID || USE_EMACS_KEY_BINDINGS
429 /**************************************************************************
430 * Arrow keys per word in non-editable element.
431 **************************************************************************/
432 #if defined(MOZ_WIDGET_ANDROID) || defined(USE_EMACS_KEY_BINDINGS)
433 {u"keypress", u"VK_LEFT", nullptr, u"control", u"cmd_wordPrevious"}, // Android, Emacs
434 {u"keypress", u"VK_RIGHT", nullptr, u"control", u"cmd_wordNext"}, // Android, Emacs
435 {u"keypress", u"VK_LEFT", nullptr, u"control,shift", u"cmd_selectWordPrevious"}, // Android, Emacs
436 {u"keypress", u"VK_RIGHT", nullptr, u"control,shift", u"cmd_selectWordNext"}, // Android, Emacs
437 #endif // MOZ_WIDGET_ANDROID || USE_EMACS_KEY_BINDINGS
438 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
439 {u"keypress", u"VK_LEFT", nullptr, u"control", u"cmd_moveLeft2"}, // Win, Linux
440 {u"keypress", u"VK_RIGHT", nullptr, u"control", u"cmd_moveRight2"}, // Win, Linux
441 {u"keypress", u"VK_LEFT", nullptr, u"control,shift", u"cmd_selectLeft2"}, // Win, Linux
442 {u"keypress", u"VK_RIGHT", nullptr, u"control,shift", u"cmd_selectRight2"}, // Win, Linux
443 #endif // XP_WIN || MOZ_WIDGET_GTK
444 #if defined(MOZ_WIDGET_COCOA)
445 {u"keypress", u"VK_LEFT", nullptr, u"alt", u"cmd_moveLeft2"}, // macOS
446 {u"keypress", u"VK_RIGHT", nullptr, u"alt", u"cmd_moveRight2"}, // macOS
447 {u"keypress", u"VK_LEFT", nullptr, u"alt,shift", u"cmd_selectLeft2"}, // macOS
448 {u"keypress", u"VK_RIGHT", nullptr, u"alt,shift", u"cmd_selectRight2"}, // macOS
449 #endif // MOZ_WIDGET_COCOA
451 /**************************************************************************
452 * Arrow keys per block in non-editable element.
453 **************************************************************************/
454 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
455 {u"keypress", u"VK_UP", nullptr, u"control", u"cmd_moveUp2"}, // Win, Linux
456 {u"keypress", u"VK_DOWN", nullptr, u"control", u"cmd_moveDown2"}, // Win, Linux
457 {u"keypress", u"VK_UP", nullptr, u"control,shift", u"cmd_selectUp2"}, // Win, Linux
458 {u"keypress", u"VK_DOWN", nullptr, u"control,shift", u"cmd_selectDown2"}, // Win, Linux
459 #endif // XP_WIN || MOZ_WIDGET_GTK
460 #if defined(MOZ_WIDGET_COCOA)
461 {u"keypress", u"VK_UP", nullptr, u"accel", u"cmd_moveUp2"}, // macOS
462 {u"keypress", u"VK_DOWN", nullptr, u"accel", u"cmd_moveDown2"}, // macOS
463 {u"keypress", u"VK_UP", nullptr, u"alt,shift", u"cmd_selectUp2"}, // macOS
464 {u"keypress", u"VK_DOWN", nullptr, u"alt,shift", u"cmd_selectDown2"}, // macOS
465 #endif // MOZ_WIDGET_COCOA
466 #if defined(MOZ_WIDGET_ANDROID)
467 {u"keypress", u"VK_UP", nullptr, u"alt", u"cmd_moveTop"}, // Android
468 {u"keypress", u"VK_DOWN", nullptr, u"alt", u"cmd_moveBottom"}, // Android
469 {u"keypress", u"VK_UP", nullptr, u"shift,alt", u"cmd_selectTop"}, // Android
470 {u"keypress", u"VK_DOWN", nullptr, u"shift,alt", u"cmd_selectBottom"}, // Android
471 #endif // MOZ_WIDGET_ANDROID
473 /**************************************************************************
474 * Arrow keys to begin/end of a line in non-editable element.
475 **************************************************************************/
476 #if defined(MOZ_WIDGET_ANDROID)
477 {u"keypress", u"VK_LEFT", nullptr, u"alt", u"cmd_beginLine"}, // Android
478 {u"keypress", u"VK_RIGHT", nullptr, u"alt", u"cmd_endLine"}, // Android
479 {u"keypress", u"VK_LEFT", nullptr, u"shift,alt", u"cmd_selectBeginLine"}, // Android
480 {u"keypress", u"VK_RIGHT", nullptr, u"shift,alt", u"cmd_selectEndLine"}, // Android
481 #endif // MOZ_WIDGET_ANDROID
483 /**************************************************************************
484 * PageUp/PageDown keys in non-editable element.
485 **************************************************************************/
486 #if defined(MOZ_WIDGET_COCOA)
487 {u"keypress", u"VK_PAGE_UP", nullptr, nullptr, u"cmd_scrollPageUp"}, // macOS
488 {u"keypress", u"VK_PAGE_DOWN", nullptr, nullptr, u"cmd_scrollPageDown"}, // macOS
489 #endif // MOZ_WIDGET_COCOA
490 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) ||\
491 defined(MOZ_WIDGET_ANDROID) || defined(USE_EMACS_KEY_BINDINGS)
492 {u"keypress", u"VK_PAGE_UP", nullptr, nullptr, u"cmd_movePageUp"}, // Win, Linux, Android, Emacs
493 {u"keypress", u"VK_PAGE_DOWN", nullptr, nullptr, u"cmd_movePageDown"}, // Win, Linux, Android, Emacs
494 {u"keypress", u"VK_PAGE_UP", nullptr, u"shift", u"cmd_selectPageUp"}, // Win, Linux, Android, Emacs
495 {u"keypress", u"VK_PAGE_DOWN", nullptr, u"shift", u"cmd_selectPageDown"}, // Win, Linux, Android, Emacs
496 #endif // XP_WIN || MOZ_WIDGET_GTK || MOZ_WIDGET_ANDROID || USE_EMACS_KEY_BINDINGS
497 #if defined(MOZ_WIDGET_ANDROID)
498 {u"keypress", u"VK_PAGE_UP", nullptr, u"alt", u"cmd_moveTop"}, // Android
499 {u"keypress", u"VK_PAGE_DOWN", nullptr, u"alt", u"cmd_moveBottom"}, // Android
500 {u"keypress", u"VK_PAGE_UP", nullptr, u"shift,alt", u"cmd_selectTop"}, // Android
501 {u"keypress", u"VK_PAGE_DOWN", nullptr, u"shift,alt", u"cmd_selectBottom"}, // Android
502 #endif // MOZ_WIDGET_ANDROID
504 /**************************************************************************
505 * Home/End keys in non-editable element.
506 **************************************************************************/
507 #if defined(MOZ_WIDGET_COCOA)
508 {u"keypress", u"VK_HOME", nullptr, nullptr, u"cmd_scrollTop"}, // macOS
509 {u"keypress", u"VK_END", nullptr, nullptr, u"cmd_scrollBottom"}, // macOS
510 #endif // MOZ_WIDGET_COCOA
511 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) ||\
512 defined(MOZ_WIDGET_ANDROID) || defined(USE_EMACS_KEY_BINDINGS)
513 {u"keypress", u"VK_HOME", nullptr, nullptr, u"cmd_beginLine"}, // Win, Linux, Android, Emacs
514 {u"keypress", u"VK_END", nullptr, nullptr, u"cmd_endLine"}, // Win, Linux, Android, Emacs
515 {u"keypress", u"VK_HOME", nullptr, u"shift", u"cmd_selectBeginLine"}, // Win, Linux, Android, Emacs
516 {u"keypress", u"VK_END", nullptr, u"shift", u"cmd_selectEndLine"}, // Win, Linux, Android, Emacs
517 {u"keypress", u"VK_HOME", nullptr, u"control", u"cmd_moveTop"}, // Win, Linux, Android, Emacs
518 {u"keypress", u"VK_END", nullptr, u"control", u"cmd_moveBottom"}, // Win, Linux, Android, Emacs
519 {u"keypress", u"VK_HOME", nullptr, u"shift,control", u"cmd_selectTop"}, // Win, Linux, Android, Emacs
520 {u"keypress", u"VK_END", nullptr, u"shift,control", u"cmd_selectBottom"}, // Win, Linux, Android, Emacs
521 #endif // XP_WIN || MOZ_WIDGET_GTK || MOZ_WIDGET_ANDROID || USE_EMACS_KEY_BINDINGS
523 /**************************************************************************
524 * Insert key in non-editable element.
525 **************************************************************************/
526 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) ||\
527 defined(USE_EMACS_KEY_BINDINGS)
528 {u"keypress", u"VK_INSERT", nullptr, u"control", u"cmd_copy"}, // Win, Linux, Emacs
529 #endif // XP_WIN || MOZ_WIDGET_GTK || USE_EMACS_KEY_BINDINGS
531 /**************************************************************************
532 * Delete key in non-editable element.
533 **************************************************************************/
534 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) ||\
535 defined(USE_EMACS_KEY_BINDINGS)
536 {u"keypress", u"VK_DELETE", nullptr, u"shift", u"cmd_cut"}, // Win, Linux, Emacs
537 #endif // XP_WIN || MOZ_WIDGET_GTK || USE_EMACS_KEY_BINDINGS
538 #if defined(MOZ_WIDGET_GTK) || defined(USE_EMACS_KEY_BINDINGS)
539 {u"keypress", u"VK_DELETE", nullptr, u"control", u"cmd_copy"}, // Linux, Emacs
540 #endif // MOZ_WIDGET_GTK || USE_EMACS_KEY_BINDINGS
541 #if defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID)
542 {u"keypress", u"VK_DELETE", nullptr, u"control", u"cmd_deleteWordForward"}, // Win, Android
543 #endif // XP_WIN || MOZ_WIDGET_ANDROID
544 #if defined(MOZ_WIDGET_ANDROID)
545 {u"keypress", u"VK_DELETE", nullptr, u"alt", u"cmd_deleteToEndOfLine"}, // Android
546 #endif // MOZ_WIDGET_ANDROID
548 /**************************************************************************
549 * Backspace key in non-editable element.
550 **************************************************************************/
551 #if defined(MOZ_WIDGET_ANDROID)
552 {u"keypress", u"VK_BACK", nullptr, u"alt", u"cmd_deleteToBeginningOfLine"}, // Android
553 {u"keypress", u"VK_BACK", nullptr, u"control", u"cmd_deleteWordBackward"}, // Android
554 #endif // MOZ_WIDGET_ANDROID
556 /**************************************************************************
557 * Common editor commands in non-editable element.
558 **************************************************************************/
559 {u"keypress", nullptr, u"c", u"accel", u"cmd_copy"}, // Win, macOS, Linux, Android, Emacs
560 {u"keypress", nullptr, u"x", u"accel", u"cmd_cut"}, // Win, macOS, Linux, Android, Emacs
561 {u"keypress", nullptr, u"v", u"accel", u"cmd_paste"}, // Win, macOS, Linux, Android, Emacs
562 {u"keypress", nullptr, u"v", u"accel,shift", u"cmd_pasteNoFormatting"}, // Win, macOS, Linux, Android, Emacs
563 {u"keypress", nullptr, u"z", u"accel", u"cmd_undo"}, // Win, macOS, Linux, Android, Emacs
564 {u"keypress", nullptr, u"z", u"accel,shift", u"cmd_redo"}, // Win, macOS, Linux, Android, Emacs
566 // Mac uses Option+Shift+Command+V for Paste and Match Style
567 #if defined(MOZ_WIDGET_COCOA)
568 {u"keypress", nullptr, u"v", u"accel,alt,shift", u"cmd_pasteNoFormatting"}, // macOS
569 #endif // MOZ_WIDGET_COCOA
571 #if defined(XP_WIN)
572 {u"keypress", nullptr, u"y", u"accel", u"cmd_redo"}, // Win
573 #endif // XP_WIN
575 {u"keypress", nullptr, u"a", u"accel", u"cmd_selectAll"}, // Win, macOS, Linux, Android, Emacs
576 #if defined(USE_EMACS_KEY_BINDINGS)
577 {u"keypress", nullptr, u"a", u"alt", u"cmd_selectAll"}, // Emacs
578 #endif // USE_EMACS_KEY_BINDINGS
580 /**************************************************************************
581 * Space key in non-editable element.
582 **************************************************************************/
583 {u"keypress", nullptr, u" ", nullptr, u"cmd_scrollPageDown"}, // Win, macOS, Linux, Android, Emacs
584 {u"keypress", nullptr, u" ", u"shift", u"cmd_scrollPageUp"}, // Win, macOS, Linux, Android, Emacs
587 {nullptr, nullptr, nullptr, nullptr, nullptr}};
589 ShortcutKeyData ShortcutKeys::sEditorHandlers[] = {
590 // clang-format off
591 /**************************************************************************
592 * Arrow keys to move caret in HTMLEditor.
593 **************************************************************************/
594 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || \
595 defined(MOZ_WIDGET_ANDROID) || defined(USE_EMACS_KEY_BINDINGS)
596 {u"keypress", u"VK_LEFT", nullptr, nullptr, u"cmd_moveLeft"}, // Win, Linux, Android, Emacs
597 {u"keypress", u"VK_RIGHT", nullptr, nullptr, u"cmd_moveRight"}, // Win, Linux, Android, Emacs
598 {u"keypress", u"VK_UP", nullptr, nullptr, u"cmd_moveUp"}, // Win, Linux, Android, Emacs
599 {u"keypress", u"VK_DOWN", nullptr, nullptr, u"cmd_moveDown"}, // Win, Linux, Android, Emacs
600 #endif // Except MOZ_WIDGET_COCOA
602 /**************************************************************************
603 * Arrow keys to select a char/line in HTMLEditor.
604 **************************************************************************/
605 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || \
606 defined(MOZ_WIDGET_ANDROID) || defined(USE_EMACS_KEY_BINDINGS)
607 {u"keypress", u"VK_LEFT", nullptr, u"shift", u"cmd_selectLeft"}, // Win, Linux, Android, Emacs
608 {u"keypress", u"VK_RIGHT", nullptr, u"shift", u"cmd_selectRight"}, // Win, Linux, Android, Emacs
609 {u"keypress", u"VK_UP", nullptr, u"shift", u"cmd_selectUp"}, // Win, Linux, Android, Emacs
610 {u"keypress", u"VK_DOWN", nullptr, u"shift", u"cmd_selectDown"}, // Win, Linux, Android, Emacs
611 #endif // Except MOZ_WIDGET_COCOA
613 /**************************************************************************
614 * Arrow keys per word in HTMLEditor.
615 **************************************************************************/
616 #if defined(MOZ_WIDGET_ANDROID) || defined(USE_EMACS_KEY_BINDINGS)
617 {u"keypress", u"VK_LEFT", nullptr, u"control", u"cmd_wordPrevious"}, // Android, Emacs
618 {u"keypress", u"VK_RIGHT", nullptr, u"control", u"cmd_wordNext"}, // Android, Emacs
619 {u"keypress", u"VK_LEFT", nullptr, u"shift,control", u"cmd_selectWordPrevious"}, // Android, Emacs
620 {u"keypress", u"VK_RIGHT", nullptr, u"shift,control", u"cmd_selectWordNext"}, // Android, Emacs
621 #endif // MOZ_WIDGET_ANDROID || USE_EMACS_KEY_BINDINGS
622 #if defined(XP_WIN)
623 {u"keypress", u"VK_LEFT", nullptr, u"accel", u"cmd_moveLeft2"}, // Win
624 {u"keypress", u"VK_RIGHT", nullptr, u"accel", u"cmd_moveRight2"}, // Win
625 {u"keypress", u"VK_LEFT", nullptr, u"shift,accel", u"cmd_selectLeft2"}, // Win
626 {u"keypress", u"VK_RIGHT", nullptr, u"shift,accel", u"cmd_selectRight2"}, // Win
627 #endif // XP_WIN
629 /**************************************************************************
630 * Arrow keys per block in HTMLEditor.
631 **************************************************************************/
632 #if defined(MOZ_WIDGET_ANDROID)
633 {u"keypress", u"VK_UP", nullptr, u"alt", u"cmd_moveTop"}, // Android
634 {u"keypress", u"VK_DOWN", nullptr, u"alt", u"cmd_moveBottom"}, // Android
635 {u"keypress", u"VK_UP", nullptr, u"shift,alt", u"cmd_selectTop"}, // Android
636 {u"keypress", u"VK_DOWN", nullptr, u"shift,alt", u"cmd_selectBottom"}, // Android
637 #endif // MOZ_WIDGET_ANDROID
638 #if defined(XP_WIN)
639 {u"keypress", u"VK_UP", nullptr, u"accel", u"cmd_moveUp2"}, // Win
640 {u"keypress", u"VK_DOWN", nullptr, u"accel", u"cmd_moveDown2"}, // Win
641 {u"keypress", u"VK_UP", nullptr, u"shift,accel", u"cmd_selectUp2"}, // Win
642 {u"keypress", u"VK_DOWN", nullptr, u"shift,accel", u"cmd_selectDown2"}, // Win
643 #endif // XP_WIN
645 /**************************************************************************
646 * Arrow keys to begin/end of a line in HTMLEditor.
647 **************************************************************************/
648 #if defined(MOZ_WIDGET_ANDROID)
649 {u"keypress", u"VK_LEFT", nullptr, u"alt", u"cmd_beginLine"}, // Android
650 {u"keypress", u"VK_RIGHT", nullptr, u"alt", u"cmd_endLine"}, // Android
651 {u"keypress", u"VK_LEFT", nullptr, u"shift,alt", u"cmd_selectBeginLine"}, // Android
652 {u"keypress", u"VK_RIGHT", nullptr, u"shift,alt", u"cmd_selectEndLine"}, // Android
653 #endif // MOZ_WIDGET_ANDROID
655 /**************************************************************************
656 * PageUp/PageDown keys in HTMLEditor.
657 **************************************************************************/
658 #if defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID) ||\
659 defined(USE_EMACS_KEY_BINDINGS)
660 {u"keypress", u"VK_PAGE_UP", nullptr, nullptr, u"cmd_movePageUp"}, // Win, Android, Emacs
661 {u"keypress", u"VK_PAGE_DOWN", nullptr, nullptr, u"cmd_movePageDown"}, // Win, Android, Emacs
662 {u"keypress", u"VK_PAGE_UP", nullptr, u"shift", u"cmd_selectPageUp"}, // Win, Android, Emacs
663 {u"keypress", u"VK_PAGE_DOWN", nullptr, u"shift", u"cmd_selectPageDown"}, // Win, Android, Emacs
664 #endif // XP_WIN || MOZ_WIDGET_ANDROID || USE_EMACS_KEY_BINDINGS
665 #if defined(MOZ_WIDGET_ANDROID)
666 {u"keypress", u"VK_PAGE_UP", nullptr, u"alt", u"cmd_moveTop"}, // Android
667 {u"keypress", u"VK_PAGE_DOWN", nullptr, u"alt", u"cmd_moveBottom"}, // Android
668 {u"keypress", u"VK_PAGE_UP", nullptr, u"shift,alt", u"cmd_selectTop"}, // Android
669 {u"keypress", u"VK_PAGE_DOWN", nullptr, u"shift,alt", u"cmd_selectBottom"}, // Android
670 #endif // MOZ_WIDGET_ANDROID
672 /**************************************************************************
673 * Home/End keys in HTMLEditor.
674 **************************************************************************/
675 #if defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID) ||\
676 defined(USE_EMACS_KEY_BINDINGS)
677 {u"keypress", u"VK_HOME", nullptr, nullptr, u"cmd_beginLine"}, // Win, Android, Emacs
678 {u"keypress", u"VK_END", nullptr, nullptr, u"cmd_endLine"}, // Win, Android, Emacs
679 {u"keypress", u"VK_HOME", nullptr, u"shift", u"cmd_selectBeginLine"}, // Win, Android, Emacs
680 {u"keypress", u"VK_END", nullptr, u"shift", u"cmd_selectEndLine"}, // Win, Android, Emacs
681 {u"keypress", u"VK_HOME", nullptr, u"control", u"cmd_moveTop"}, // Win, Android, Emacs
682 {u"keypress", u"VK_END", nullptr, u"control", u"cmd_moveBottom"}, // Win, Android, Emacs
683 {u"keypress", u"VK_HOME", nullptr, u"shift,control", u"cmd_selectTop"}, // Win, Android, Emacs
684 {u"keypress", u"VK_END", nullptr, u"shift,control", u"cmd_selectBottom"}, // Win, Android, Emacs
685 #endif // XP_WIN || MOZ_WIDGET_ANDROID || USE_EMACS_KEY_BINDINGS
687 /**************************************************************************
688 * Insert key in HTMLEditor.
689 **************************************************************************/
690 #if defined(XP_WIN) || defined(USE_EMACS_KEY_BINDINGS)
691 {u"keypress", u"VK_INSERT", nullptr, u"control", u"cmd_copy"}, // Win, Emacs
692 {u"keypress", u"VK_INSERT", nullptr, u"shift", u"cmd_paste"}, // Win, Emacs
693 #endif // XP_WIN || USE_EMACS_KEY_BINDINGS
695 /**************************************************************************
696 * Delete key in HTMLEditor.
697 **************************************************************************/
698 #if defined(XP_WIN) || defined(USE_EMACS_KEY_BINDINGS)
699 {u"keypress", u"VK_DELETE", nullptr, u"shift", u"cmd_cutOrDelete"}, // Win, Emacs
700 #endif // XP_WIN || USE_EMACS_KEY_BINDINGS
701 #if defined(USE_EMACS_KEY_BINDINGS)
702 {u"keypress", u"VK_DELETE", nullptr, u"control", u"cmd_copyOrDelete"}, // Emacs
703 #endif // USE_EMACS_KEY_BINDINGS
704 #if defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID)
705 {u"keypress", u"VK_DELETE", nullptr, u"control", u"cmd_deleteWordForward"}, // Win, Android
706 #endif // XP_WIN || MOZ_WIDGET_ANDROID
707 #if defined(MOZ_WIDGET_ANDROID)
708 {u"keypress", u"VK_DELETE", nullptr, u"alt", u"cmd_deleteToEndOfLine"}, // Android
709 #endif // MOZ_WIDGET_ANDROID
711 /**************************************************************************
712 * Backspace key in HTMLEditor.
713 **************************************************************************/
714 #if defined(XP_WIN) || defined(MOZ_WIDGET_ANDROID) || defined(USE_EMACS_KEY_BINDINGS)
715 {u"keypress", u"VK_BACK", nullptr, u"control", u"cmd_deleteWordBackward"}, // Win, Android, Emacs
716 #endif // XP_WIN || MOZ_WIDGET_ANDROID || USE_EMACS_KEY_BINDINGS
717 #if defined(MOZ_WIDGET_ANDROID)
718 {u"keypress", u"VK_BACK", nullptr, u"alt", u"cmd_deleteToBeginningOfLine"}, // Android
719 #endif // MOZ_WIDGET_ANDROID
720 #if defined(XP_WIN)
721 {u"keypress", u"VK_BACK", nullptr, u"alt", u"cmd_undo"}, // Win
722 {u"keypress", u"VK_BACK", nullptr, u"alt,shift", u"cmd_redo"}, // Win
723 #endif // XP_WIN
725 /**************************************************************************
726 * Common editor commands in HTMLEditor.
727 **************************************************************************/
728 {u"keypress", nullptr, u"c", u"accel", u"cmd_copy"}, // Win, macOS, Linux, Android, Emacs
729 {u"keypress", nullptr, u"x", u"accel", u"cmd_cut"}, // Win, macOS, Linux, Android, Emacs
730 {u"keypress", nullptr, u"v", u"accel", u"cmd_paste"}, // Win, macOS, Linux, Android, Emacs
731 {u"keypress", nullptr, u"v", u"accel,shift", u"cmd_pasteNoFormatting"}, // Win, macOS, Linux, Android, Emacs
732 {u"keypress", nullptr, u"z", u"accel", u"cmd_undo"}, // Win, macOS, Linux, Android, Emacs
733 {u"keypress", nullptr, u"z", u"accel,shift", u"cmd_redo"}, // Win, macOS, Linux, Android, Emacs
735 // Mac uses Option+Shift+Command+V for Paste and Match Style
736 #if defined(MOZ_WIDGET_COCOA)
737 {u"keypress", nullptr, u"v", u"accel,alt,shift", u"cmd_pasteNoFormatting"}, // macOS
738 #endif // MOZ_WIDGET_COCOA
740 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) ||\
741 defined(USE_EMACS_KEY_BINDINGS)
742 {u"keypress", nullptr, u"y", u"accel", u"cmd_redo"}, // Emacs
743 #endif // XP_WIN || MOZ_WIDGET_GTK || USE_EMACS_KEY_BINDINGS
745 #if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_GTK) ||\
746 defined(MOZ_WIDGET_ANDROID)
747 {u"keypress", nullptr, u"a", u"accel", u"cmd_selectAll"}, // Win, macOS, Linux, Android
748 #endif // XP_WIN || MOZ_WIDGET_COCOA || MOZ_WIDGET_GTK || MOZ_WIDGET_ANDROID
749 #if defined(USE_EMACS_KEY_BINDINGS)
750 {u"keypress", nullptr, u"a", u"alt", u"cmd_selectAll"}, // Emacs
751 #endif // USE_EMACS_KEY_BINDINGS
753 /**************************************************************************
754 * Space key in HTMLEditor.
755 **************************************************************************/
756 {u"keypress", nullptr, u" ", nullptr, u"cmd_scrollPageDown"}, // Win, macOS, Linux, Android, Emacs
757 {u"keypress", nullptr, u" ", u"shift", u"cmd_scrollPageUp"}, // Win, macOS, Linux, Android, Emacs
759 /**************************************************************************
760 * Emacs specific shortcut keys in HTMLEditor.
761 **************************************************************************/
762 #if defined(USE_EMACS_KEY_BINDINGS)
763 {u"keypress", nullptr, u"h", u"control", u"cmd_deleteCharBackward"}, // Emacs
764 {u"keypress", nullptr, u"d", u"control", u"cmd_deleteCharForward"}, // Emacs
765 {u"keypress", nullptr, u"k", u"control", u"cmd_deleteToEndOfLine"}, // Emacs
766 {u"keypress", nullptr, u"u", u"control", u"cmd_deleteToBeginningOfLine"}, // Emacs
767 {u"keypress", nullptr, u"a", u"control", u"cmd_beginLine"}, // Emacs
768 {u"keypress", nullptr, u"e", u"control", u"cmd_endLine"}, // Emacs
769 {u"keypress", nullptr, u"b", u"control", u"cmd_charPrevious"}, // Emacs
770 {u"keypress", nullptr, u"f", u"control", u"cmd_charNext"}, // Emacs
771 {u"keypress", nullptr, u"p", u"control", u"cmd_linePrevious"}, // Emacs
772 {u"keypress", nullptr, u"n", u"control", u"cmd_lineNext"}, // Emacs
773 #endif // USE_EMACS_KEY_BINDINGS
774 // clang-format on
776 {nullptr, nullptr, nullptr, nullptr, nullptr}};
778 } // namespace mozilla
780 #undef USE_EMACS_KEY_BINDINGS