]> git.proxmox.com Git - mirror_novnc.git/blame - core/input/domkeytable.js
Use toggle keysym for Eisu key
[mirror_novnc.git] / core / input / domkeytable.js
CommitLineData
9782d4a3
PO
1/*
2 * noVNC: HTML5 VNC client
84586c0f 3 * Copyright (C) 2018 The noVNC Authors
9782d4a3
PO
4 * Licensed under MPL 2.0 or any later version (see LICENSE.txt)
5 */
6
afb621d5 7import KeyTable from "./keysym.js";
9782d4a3
PO
8
9/*
10 * Mapping between HTML key values and VNC/X11 keysyms for "special"
11 * keys that cannot be handled via their Unicode codepoint.
12 *
13 * See https://www.w3.org/TR/uievents-key/ for possible values.
14 */
15
2b5f94fa 16const DOMKeyTable = {};
9782d4a3 17
a9888115 18function addStandard(key, standard) {
84a5a2d8
JD
19 if (standard === undefined) throw new Error("Undefined keysym for key \"" + key + "\"");
20 if (key in DOMKeyTable) throw new Error("Duplicate entry for key \"" + key + "\"");
9782d4a3
PO
21 DOMKeyTable[key] = [standard, standard, standard, standard];
22}
23
a9888115 24function addLeftRight(key, left, right) {
84a5a2d8
JD
25 if (left === undefined) throw new Error("Undefined keysym for key \"" + key + "\"");
26 if (right === undefined) throw new Error("Undefined keysym for key \"" + key + "\"");
27 if (key in DOMKeyTable) throw new Error("Duplicate entry for key \"" + key + "\"");
9782d4a3
PO
28 DOMKeyTable[key] = [left, left, right, left];
29}
30
a9888115 31function addNumpad(key, standard, numpad) {
84a5a2d8
JD
32 if (standard === undefined) throw new Error("Undefined keysym for key \"" + key + "\"");
33 if (numpad === undefined) throw new Error("Undefined keysym for key \"" + key + "\"");
34 if (key in DOMKeyTable) throw new Error("Duplicate entry for key \"" + key + "\"");
9782d4a3
PO
35 DOMKeyTable[key] = [standard, standard, standard, numpad];
36}
37
38// 2.2. Modifier Keys
39
40addLeftRight("Alt", KeyTable.XK_Alt_L, KeyTable.XK_Alt_R);
41addStandard("AltGraph", KeyTable.XK_ISO_Level3_Shift);
42addStandard("CapsLock", KeyTable.XK_Caps_Lock);
43addLeftRight("Control", KeyTable.XK_Control_L, KeyTable.XK_Control_R);
44// - Fn
45// - FnLock
9782d4a3
PO
46addLeftRight("Meta", KeyTable.XK_Super_L, KeyTable.XK_Super_R);
47addStandard("NumLock", KeyTable.XK_Num_Lock);
48addStandard("ScrollLock", KeyTable.XK_Scroll_Lock);
49addLeftRight("Shift", KeyTable.XK_Shift_L, KeyTable.XK_Shift_R);
9782d4a3
PO
50// - Symbol
51// - SymbolLock
52
53// 2.3. Whitespace Keys
54
55addNumpad("Enter", KeyTable.XK_Return, KeyTable.XK_KP_Enter);
56addStandard("Tab", KeyTable.XK_Tab);
57addNumpad(" ", KeyTable.XK_space, KeyTable.XK_KP_Space);
58
59// 2.4. Navigation Keys
60
61addNumpad("ArrowDown", KeyTable.XK_Down, KeyTable.XK_KP_Down);
62addNumpad("ArrowUp", KeyTable.XK_Up, KeyTable.XK_KP_Up);
63addNumpad("ArrowLeft", KeyTable.XK_Left, KeyTable.XK_KP_Left);
64addNumpad("ArrowRight", KeyTable.XK_Right, KeyTable.XK_KP_Right);
65addNumpad("End", KeyTable.XK_End, KeyTable.XK_KP_End);
66addNumpad("Home", KeyTable.XK_Home, KeyTable.XK_KP_Home);
67addNumpad("PageDown", KeyTable.XK_Next, KeyTable.XK_KP_Next);
68addNumpad("PageUp", KeyTable.XK_Prior, KeyTable.XK_KP_Prior);
69
70// 2.5. Editing Keys
71
72addStandard("Backspace", KeyTable.XK_BackSpace);
dd4341fe
PO
73// Browsers send "Clear" for the numpad 5 without NumLock because
74// Windows uses VK_Clear for that key. But Unix expects KP_Begin for
75// that scenario.
5858f472 76addNumpad("Clear", KeyTable.XK_Clear, KeyTable.XK_KP_Begin);
9782d4a3
PO
77addStandard("Copy", KeyTable.XF86XK_Copy);
78// - CrSel
79addStandard("Cut", KeyTable.XF86XK_Cut);
80addNumpad("Delete", KeyTable.XK_Delete, KeyTable.XK_KP_Delete);
81// - EraseEof
82// - ExSel
83addNumpad("Insert", KeyTable.XK_Insert, KeyTable.XK_KP_Insert);
84addStandard("Paste", KeyTable.XF86XK_Paste);
85addStandard("Redo", KeyTable.XK_Redo);
86addStandard("Undo", KeyTable.XK_Undo);
87
88// 2.6. UI Keys
89
90// - Accept
91// - Again (could just be XK_Redo)
92// - Attn
93addStandard("Cancel", KeyTable.XK_Cancel);
94addStandard("ContextMenu", KeyTable.XK_Menu);
95addStandard("Escape", KeyTable.XK_Escape);
96addStandard("Execute", KeyTable.XK_Execute);
97addStandard("Find", KeyTable.XK_Find);
98addStandard("Help", KeyTable.XK_Help);
99addStandard("Pause", KeyTable.XK_Pause);
100// - Play
101// - Props
102addStandard("Select", KeyTable.XK_Select);
103addStandard("ZoomIn", KeyTable.XF86XK_ZoomIn);
104addStandard("ZoomOut", KeyTable.XF86XK_ZoomOut);
105
106// 2.7. Device Keys
107
108addStandard("BrightnessDown", KeyTable.XF86XK_MonBrightnessDown);
109addStandard("BrightnessUp", KeyTable.XF86XK_MonBrightnessUp);
110addStandard("Eject", KeyTable.XF86XK_Eject);
111addStandard("LogOff", KeyTable.XF86XK_LogOff);
112addStandard("Power", KeyTable.XF86XK_PowerOff);
113addStandard("PowerOff", KeyTable.XF86XK_PowerDown);
114addStandard("PrintScreen", KeyTable.XK_Print);
115addStandard("Hibernate", KeyTable.XF86XK_Hibernate);
116addStandard("Standby", KeyTable.XF86XK_Standby);
117addStandard("WakeUp", KeyTable.XF86XK_WakeUp);
118
119// 2.8. IME and Composition Keys
120
121addStandard("AllCandidates", KeyTable.XK_MultipleCandidate);
bd1bb2ed 122addStandard("Alphanumeric", KeyTable.XK_Eisu_toggle);
9782d4a3
PO
123addStandard("CodeInput", KeyTable.XK_Codeinput);
124addStandard("Compose", KeyTable.XK_Multi_key);
125addStandard("Convert", KeyTable.XK_Henkan);
126// - Dead
127// - FinalMode
128addStandard("GroupFirst", KeyTable.XK_ISO_First_Group);
129addStandard("GroupLast", KeyTable.XK_ISO_Last_Group);
130addStandard("GroupNext", KeyTable.XK_ISO_Next_Group);
131addStandard("GroupPrevious", KeyTable.XK_ISO_Prev_Group);
132// - ModeChange (XK_Mode_switch is often used for AltGr)
133// - NextCandidate
134addStandard("NonConvert", KeyTable.XK_Muhenkan);
135addStandard("PreviousCandidate", KeyTable.XK_PreviousCandidate);
136// - Process
137addStandard("SingleCandidate", KeyTable.XK_SingleCandidate);
138addStandard("HangulMode", KeyTable.XK_Hangul);
139addStandard("HanjaMode", KeyTable.XK_Hangul_Hanja);
140addStandard("JunjuaMode", KeyTable.XK_Hangul_Jeonja);
141addStandard("Eisu", KeyTable.XK_Eisu_toggle);
142addStandard("Hankaku", KeyTable.XK_Hankaku);
143addStandard("Hiragana", KeyTable.XK_Hiragana);
144addStandard("HiraganaKatakana", KeyTable.XK_Hiragana_Katakana);
145addStandard("KanaMode", KeyTable.XK_Kana_Shift); // could also be _Kana_Lock
146addStandard("KanjiMode", KeyTable.XK_Kanji);
147addStandard("Katakana", KeyTable.XK_Katakana);
148addStandard("Romaji", KeyTable.XK_Romaji);
149addStandard("Zenkaku", KeyTable.XK_Zenkaku);
150addStandard("ZenkakuHanaku", KeyTable.XK_Zenkaku_Hankaku);
151
152// 2.9. General-Purpose Function Keys
153
154addStandard("F1", KeyTable.XK_F1);
155addStandard("F2", KeyTable.XK_F2);
156addStandard("F3", KeyTable.XK_F3);
157addStandard("F4", KeyTable.XK_F4);
158addStandard("F5", KeyTable.XK_F5);
159addStandard("F6", KeyTable.XK_F6);
160addStandard("F7", KeyTable.XK_F7);
161addStandard("F8", KeyTable.XK_F8);
162addStandard("F9", KeyTable.XK_F9);
163addStandard("F10", KeyTable.XK_F10);
164addStandard("F11", KeyTable.XK_F11);
165addStandard("F12", KeyTable.XK_F12);
166addStandard("F13", KeyTable.XK_F13);
167addStandard("F14", KeyTable.XK_F14);
168addStandard("F15", KeyTable.XK_F15);
169addStandard("F16", KeyTable.XK_F16);
170addStandard("F17", KeyTable.XK_F17);
171addStandard("F18", KeyTable.XK_F18);
172addStandard("F19", KeyTable.XK_F19);
173addStandard("F20", KeyTable.XK_F20);
174addStandard("F21", KeyTable.XK_F21);
175addStandard("F22", KeyTable.XK_F22);
176addStandard("F23", KeyTable.XK_F23);
177addStandard("F24", KeyTable.XK_F24);
178addStandard("F25", KeyTable.XK_F25);
179addStandard("F26", KeyTable.XK_F26);
180addStandard("F27", KeyTable.XK_F27);
181addStandard("F28", KeyTable.XK_F28);
182addStandard("F29", KeyTable.XK_F29);
183addStandard("F30", KeyTable.XK_F30);
184addStandard("F31", KeyTable.XK_F31);
185addStandard("F32", KeyTable.XK_F32);
186addStandard("F33", KeyTable.XK_F33);
187addStandard("F34", KeyTable.XK_F34);
188addStandard("F35", KeyTable.XK_F35);
189// - Soft1...
190
191// 2.10. Multimedia Keys
192
193// - ChannelDown
194// - ChannelUp
195addStandard("Close", KeyTable.XF86XK_Close);
196addStandard("MailForward", KeyTable.XF86XK_MailForward);
197addStandard("MailReply", KeyTable.XF86XK_Reply);
10965554 198addStandard("MailSend", KeyTable.XF86XK_Send);
ebee9cdd 199// - MediaClose
9782d4a3
PO
200addStandard("MediaFastForward", KeyTable.XF86XK_AudioForward);
201addStandard("MediaPause", KeyTable.XF86XK_AudioPause);
202addStandard("MediaPlay", KeyTable.XF86XK_AudioPlay);
203addStandard("MediaRecord", KeyTable.XF86XK_AudioRecord);
204addStandard("MediaRewind", KeyTable.XF86XK_AudioRewind);
205addStandard("MediaStop", KeyTable.XF86XK_AudioStop);
206addStandard("MediaTrackNext", KeyTable.XF86XK_AudioNext);
207addStandard("MediaTrackPrevious", KeyTable.XF86XK_AudioPrev);
208addStandard("New", KeyTable.XF86XK_New);
209addStandard("Open", KeyTable.XF86XK_Open);
210addStandard("Print", KeyTable.XK_Print);
211addStandard("Save", KeyTable.XF86XK_Save);
212addStandard("SpellCheck", KeyTable.XF86XK_Spell);
213
214// 2.11. Multimedia Numpad Keys
215
216// - Key11
217// - Key12
218
219// 2.12. Audio Keys
220
221// - AudioBalanceLeft
222// - AudioBalanceRight
9782d4a3
PO
223// - AudioBassBoostDown
224// - AudioBassBoostToggle
225// - AudioBassBoostUp
9782d4a3
PO
226// - AudioFaderFront
227// - AudioFaderRear
228// - AudioSurroundModeNext
229// - AudioTrebleDown
230// - AudioTrebleUp
231addStandard("AudioVolumeDown", KeyTable.XF86XK_AudioLowerVolume);
232addStandard("AudioVolumeUp", KeyTable.XF86XK_AudioRaiseVolume);
233addStandard("AudioVolumeMute", KeyTable.XF86XK_AudioMute);
234// - MicrophoneToggle
235// - MicrophoneVolumeDown
236// - MicrophoneVolumeUp
237addStandard("MicrophoneVolumeMute", KeyTable.XF86XK_AudioMicMute);
238
239// 2.13. Speech Keys
240
241// - SpeechCorrectionList
242// - SpeechInputToggle
243
244// 2.14. Application Keys
245
ebee9cdd
PO
246addStandard("LaunchApplication1", KeyTable.XF86XK_MyComputer);
247addStandard("LaunchApplication2", KeyTable.XF86XK_Calculator);
9782d4a3
PO
248addStandard("LaunchCalendar", KeyTable.XF86XK_Calendar);
249addStandard("LaunchMail", KeyTable.XF86XK_Mail);
250addStandard("LaunchMediaPlayer", KeyTable.XF86XK_AudioMedia);
251addStandard("LaunchMusicPlayer", KeyTable.XF86XK_Music);
9782d4a3
PO
252addStandard("LaunchPhone", KeyTable.XF86XK_Phone);
253addStandard("LaunchScreenSaver", KeyTable.XF86XK_ScreenSaver);
254addStandard("LaunchSpreadsheet", KeyTable.XF86XK_Excel);
255addStandard("LaunchWebBrowser", KeyTable.XF86XK_WWW);
256addStandard("LaunchWebCam", KeyTable.XF86XK_WebCam);
257addStandard("LaunchWordProcessor", KeyTable.XF86XK_Word);
258
259// 2.15. Browser Keys
260
261addStandard("BrowserBack", KeyTable.XF86XK_Back);
262addStandard("BrowserFavorites", KeyTable.XF86XK_Favorites);
263addStandard("BrowserForward", KeyTable.XF86XK_Forward);
264addStandard("BrowserHome", KeyTable.XF86XK_HomePage);
265addStandard("BrowserRefresh", KeyTable.XF86XK_Refresh);
266addStandard("BrowserSearch", KeyTable.XF86XK_Search);
267addStandard("BrowserStop", KeyTable.XF86XK_Stop);
268
269// 2.16. Mobile Phone Keys
270
271// - A whole bunch...
272
273// 2.17. TV Keys
274
275// - A whole bunch...
276
277// 2.18. Media Controller Keys
278
279// - A whole bunch...
280addStandard("Dimmer", KeyTable.XF86XK_BrightnessAdjust);
281addStandard("MediaAudioTrack", KeyTable.XF86XK_AudioCycleTrack);
282addStandard("RandomToggle", KeyTable.XF86XK_AudioRandomPlay);
283addStandard("SplitScreenToggle", KeyTable.XF86XK_SplitScreen);
284addStandard("Subtitle", KeyTable.XF86XK_Subtitle);
285addStandard("VideoModeNext", KeyTable.XF86XK_Next_VMode);
286
287// Extra: Numpad
288
289addNumpad("=", KeyTable.XK_equal, KeyTable.XK_KP_Equal);
290addNumpad("+", KeyTable.XK_plus, KeyTable.XK_KP_Add);
291addNumpad("-", KeyTable.XK_minus, KeyTable.XK_KP_Subtract);
292addNumpad("*", KeyTable.XK_asterisk, KeyTable.XK_KP_Multiply);
293addNumpad("/", KeyTable.XK_slash, KeyTable.XK_KP_Divide);
294addNumpad(".", KeyTable.XK_period, KeyTable.XK_KP_Decimal);
295addNumpad(",", KeyTable.XK_comma, KeyTable.XK_KP_Separator);
296addNumpad("0", KeyTable.XK_0, KeyTable.XK_KP_0);
297addNumpad("1", KeyTable.XK_1, KeyTable.XK_KP_1);
298addNumpad("2", KeyTable.XK_2, KeyTable.XK_KP_2);
299addNumpad("3", KeyTable.XK_3, KeyTable.XK_KP_3);
300addNumpad("4", KeyTable.XK_4, KeyTable.XK_KP_4);
301addNumpad("5", KeyTable.XK_5, KeyTable.XK_KP_5);
302addNumpad("6", KeyTable.XK_6, KeyTable.XK_KP_6);
303addNumpad("7", KeyTable.XK_7, KeyTable.XK_KP_7);
304addNumpad("8", KeyTable.XK_8, KeyTable.XK_KP_8);
305addNumpad("9", KeyTable.XK_9, KeyTable.XK_KP_9);
306
307export default DOMKeyTable;