]>
git.proxmox.com Git - mirror_novnc.git/blob - core/input/domkeytable.js
2 * noVNC: HTML5 VNC client
3 * Copyright (C) 2017 Pierre Ossman for Cendio AB
4 * Licensed under MPL 2.0 or any later version (see LICENSE.txt)
7 import KeyTable
from "./keysym.js";
10 * Mapping between HTML key values and VNC/X11 keysyms for "special"
11 * keys that cannot be handled via their Unicode codepoint.
13 * See https://www.w3.org/TR/uievents-key/ for possible values.
18 function addStandard(key
, standard
)
20 if (standard
=== undefined) throw "Undefined keysym for key \"" + key
+ "\"";
21 if (key
in DOMKeyTable
) throw "Duplicate entry for key \"" + key
+ "\"";
22 DOMKeyTable
[key
] = [standard
, standard
, standard
, standard
];
25 function addLeftRight(key
, left
, right
)
27 if (left
=== undefined) throw "Undefined keysym for key \"" + key
+ "\"";
28 if (right
=== undefined) throw "Undefined keysym for key \"" + key
+ "\"";
29 if (key
in DOMKeyTable
) throw "Duplicate entry for key \"" + key
+ "\"";
30 DOMKeyTable
[key
] = [left
, left
, right
, left
];
33 function addNumpad(key
, standard
, numpad
)
35 if (standard
=== undefined) throw "Undefined keysym for key \"" + key
+ "\"";
36 if (numpad
=== undefined) throw "Undefined keysym for key \"" + key
+ "\"";
37 if (key
in DOMKeyTable
) throw "Duplicate entry for key \"" + key
+ "\"";
38 DOMKeyTable
[key
] = [standard
, standard
, standard
, numpad
];
43 addLeftRight("Alt", KeyTable
.XK_Alt_L
, KeyTable
.XK_Alt_R
);
44 addStandard("AltGraph", KeyTable
.XK_ISO_Level3_Shift
);
45 addStandard("CapsLock", KeyTable
.XK_Caps_Lock
);
46 addLeftRight("Control", KeyTable
.XK_Control_L
, KeyTable
.XK_Control_R
);
49 addLeftRight("Hyper", KeyTable
.XK_Super_L
, KeyTable
.XK_Super_R
);
50 addLeftRight("Meta", KeyTable
.XK_Super_L
, KeyTable
.XK_Super_R
);
51 addStandard("NumLock", KeyTable
.XK_Num_Lock
);
52 addStandard("ScrollLock", KeyTable
.XK_Scroll_Lock
);
53 addLeftRight("Shift", KeyTable
.XK_Shift_L
, KeyTable
.XK_Shift_R
);
54 addLeftRight("Super", KeyTable
.XK_Super_L
, KeyTable
.XK_Super_R
);
58 // 2.3. Whitespace Keys
60 addNumpad("Enter", KeyTable
.XK_Return
, KeyTable
.XK_KP_Enter
);
61 addStandard("Tab", KeyTable
.XK_Tab
);
62 addNumpad(" ", KeyTable
.XK_space
, KeyTable
.XK_KP_Space
);
64 // 2.4. Navigation Keys
66 addNumpad("ArrowDown", KeyTable
.XK_Down
, KeyTable
.XK_KP_Down
);
67 addNumpad("ArrowUp", KeyTable
.XK_Up
, KeyTable
.XK_KP_Up
);
68 addNumpad("ArrowLeft", KeyTable
.XK_Left
, KeyTable
.XK_KP_Left
);
69 addNumpad("ArrowRight", KeyTable
.XK_Right
, KeyTable
.XK_KP_Right
);
70 addNumpad("End", KeyTable
.XK_End
, KeyTable
.XK_KP_End
);
71 addNumpad("Home", KeyTable
.XK_Home
, KeyTable
.XK_KP_Home
);
72 addNumpad("PageDown", KeyTable
.XK_Next
, KeyTable
.XK_KP_Next
);
73 addNumpad("PageUp", KeyTable
.XK_Prior
, KeyTable
.XK_KP_Prior
);
77 addStandard("Backspace", KeyTable
.XK_BackSpace
);
78 addStandard("Clear", KeyTable
.XK_Clear
);
79 addStandard("Copy", KeyTable
.XF86XK_Copy
);
81 addStandard("Cut", KeyTable
.XF86XK_Cut
);
82 addNumpad("Delete", KeyTable
.XK_Delete
, KeyTable
.XK_KP_Delete
);
85 addNumpad("Insert", KeyTable
.XK_Insert
, KeyTable
.XK_KP_Insert
);
86 addStandard("Paste", KeyTable
.XF86XK_Paste
);
87 addStandard("Redo", KeyTable
.XK_Redo
);
88 addStandard("Undo", KeyTable
.XK_Undo
);
93 // - Again (could just be XK_Redo)
95 addStandard("Cancel", KeyTable
.XK_Cancel
);
96 addStandard("ContextMenu", KeyTable
.XK_Menu
);
97 addStandard("Escape", KeyTable
.XK_Escape
);
98 addStandard("Execute", KeyTable
.XK_Execute
);
99 addStandard("Find", KeyTable
.XK_Find
);
100 addStandard("Help", KeyTable
.XK_Help
);
101 addStandard("Pause", KeyTable
.XK_Pause
);
104 addStandard("Select", KeyTable
.XK_Select
);
105 addStandard("ZoomIn", KeyTable
.XF86XK_ZoomIn
);
106 addStandard("ZoomOut", KeyTable
.XF86XK_ZoomOut
);
110 addStandard("BrightnessDown", KeyTable
.XF86XK_MonBrightnessDown
);
111 addStandard("BrightnessUp", KeyTable
.XF86XK_MonBrightnessUp
);
112 addStandard("Eject", KeyTable
.XF86XK_Eject
);
113 addStandard("LogOff", KeyTable
.XF86XK_LogOff
);
114 addStandard("Power", KeyTable
.XF86XK_PowerOff
);
115 addStandard("PowerOff", KeyTable
.XF86XK_PowerDown
);
116 addStandard("PrintScreen", KeyTable
.XK_Print
);
117 addStandard("Hibernate", KeyTable
.XF86XK_Hibernate
);
118 addStandard("Standby", KeyTable
.XF86XK_Standby
);
119 addStandard("WakeUp", KeyTable
.XF86XK_WakeUp
);
121 // 2.8. IME and Composition Keys
123 addStandard("AllCandidates", KeyTable
.XK_MultipleCandidate
);
124 addStandard("Alphanumeric", KeyTable
.XK_Eisu_Shift
); // could also be _Eisu_Toggle
125 addStandard("CodeInput", KeyTable
.XK_Codeinput
);
126 addStandard("Compose", KeyTable
.XK_Multi_key
);
127 addStandard("Convert", KeyTable
.XK_Henkan
);
130 addStandard("GroupFirst", KeyTable
.XK_ISO_First_Group
);
131 addStandard("GroupLast", KeyTable
.XK_ISO_Last_Group
);
132 addStandard("GroupNext", KeyTable
.XK_ISO_Next_Group
);
133 addStandard("GroupPrevious", KeyTable
.XK_ISO_Prev_Group
);
134 // - ModeChange (XK_Mode_switch is often used for AltGr)
136 addStandard("NonConvert", KeyTable
.XK_Muhenkan
);
137 addStandard("PreviousCandidate", KeyTable
.XK_PreviousCandidate
);
139 addStandard("SingleCandidate", KeyTable
.XK_SingleCandidate
);
140 addStandard("HangulMode", KeyTable
.XK_Hangul
);
141 addStandard("HanjaMode", KeyTable
.XK_Hangul_Hanja
);
142 addStandard("JunjuaMode", KeyTable
.XK_Hangul_Jeonja
);
143 addStandard("Eisu", KeyTable
.XK_Eisu_toggle
);
144 addStandard("Hankaku", KeyTable
.XK_Hankaku
);
145 addStandard("Hiragana", KeyTable
.XK_Hiragana
);
146 addStandard("HiraganaKatakana", KeyTable
.XK_Hiragana_Katakana
);
147 addStandard("KanaMode", KeyTable
.XK_Kana_Shift
); // could also be _Kana_Lock
148 addStandard("KanjiMode", KeyTable
.XK_Kanji
);
149 addStandard("Katakana", KeyTable
.XK_Katakana
);
150 addStandard("Romaji", KeyTable
.XK_Romaji
);
151 addStandard("Zenkaku", KeyTable
.XK_Zenkaku
);
152 addStandard("ZenkakuHanaku", KeyTable
.XK_Zenkaku_Hankaku
);
154 // 2.9. General-Purpose Function Keys
156 addStandard("F1", KeyTable
.XK_F1
);
157 addStandard("F2", KeyTable
.XK_F2
);
158 addStandard("F3", KeyTable
.XK_F3
);
159 addStandard("F4", KeyTable
.XK_F4
);
160 addStandard("F5", KeyTable
.XK_F5
);
161 addStandard("F6", KeyTable
.XK_F6
);
162 addStandard("F7", KeyTable
.XK_F7
);
163 addStandard("F8", KeyTable
.XK_F8
);
164 addStandard("F9", KeyTable
.XK_F9
);
165 addStandard("F10", KeyTable
.XK_F10
);
166 addStandard("F11", KeyTable
.XK_F11
);
167 addStandard("F12", KeyTable
.XK_F12
);
168 addStandard("F13", KeyTable
.XK_F13
);
169 addStandard("F14", KeyTable
.XK_F14
);
170 addStandard("F15", KeyTable
.XK_F15
);
171 addStandard("F16", KeyTable
.XK_F16
);
172 addStandard("F17", KeyTable
.XK_F17
);
173 addStandard("F18", KeyTable
.XK_F18
);
174 addStandard("F19", KeyTable
.XK_F19
);
175 addStandard("F20", KeyTable
.XK_F20
);
176 addStandard("F21", KeyTable
.XK_F21
);
177 addStandard("F22", KeyTable
.XK_F22
);
178 addStandard("F23", KeyTable
.XK_F23
);
179 addStandard("F24", KeyTable
.XK_F24
);
180 addStandard("F25", KeyTable
.XK_F25
);
181 addStandard("F26", KeyTable
.XK_F26
);
182 addStandard("F27", KeyTable
.XK_F27
);
183 addStandard("F28", KeyTable
.XK_F28
);
184 addStandard("F29", KeyTable
.XK_F29
);
185 addStandard("F30", KeyTable
.XK_F30
);
186 addStandard("F31", KeyTable
.XK_F31
);
187 addStandard("F32", KeyTable
.XK_F32
);
188 addStandard("F33", KeyTable
.XK_F33
);
189 addStandard("F34", KeyTable
.XK_F34
);
190 addStandard("F35", KeyTable
.XK_F35
);
193 // 2.10. Multimedia Keys
197 addStandard("Close", KeyTable
.XF86XK_Close
);
198 addStandard("MailForward", KeyTable
.XF86XK_MailForward
);
199 addStandard("MailReply", KeyTable
.XF86XK_Reply
);
200 addStandard("MainSend", KeyTable
.XF86XK_Send
);
201 addStandard("MediaFastForward", KeyTable
.XF86XK_AudioForward
);
202 addStandard("MediaPause", KeyTable
.XF86XK_AudioPause
);
203 addStandard("MediaPlay", KeyTable
.XF86XK_AudioPlay
);
204 addStandard("MediaRecord", KeyTable
.XF86XK_AudioRecord
);
205 addStandard("MediaRewind", KeyTable
.XF86XK_AudioRewind
);
206 addStandard("MediaStop", KeyTable
.XF86XK_AudioStop
);
207 addStandard("MediaTrackNext", KeyTable
.XF86XK_AudioNext
);
208 addStandard("MediaTrackPrevious", KeyTable
.XF86XK_AudioPrev
);
209 addStandard("New", KeyTable
.XF86XK_New
);
210 addStandard("Open", KeyTable
.XF86XK_Open
);
211 addStandard("Print", KeyTable
.XK_Print
);
212 addStandard("Save", KeyTable
.XF86XK_Save
);
213 addStandard("SpellCheck", KeyTable
.XF86XK_Spell
);
215 // 2.11. Multimedia Numpad Keys
222 // - AudioBalanceLeft
223 // - AudioBalanceRight
225 // - AudioBassBoostDown
226 // - AudioBassBoostToggle
227 // - AudioBassBoostUp
231 // - AudioSurroundModeNext
234 addStandard("AudioVolumeDown", KeyTable
.XF86XK_AudioLowerVolume
);
235 addStandard("AudioVolumeUp", KeyTable
.XF86XK_AudioRaiseVolume
);
236 addStandard("AudioVolumeMute", KeyTable
.XF86XK_AudioMute
);
237 // - MicrophoneToggle
238 // - MicrophoneVolumeDown
239 // - MicrophoneVolumeUp
240 addStandard("MicrophoneVolumeMute", KeyTable
.XF86XK_AudioMicMute
);
244 // - SpeechCorrectionList
245 // - SpeechInputToggle
247 // 2.14. Application Keys
249 addStandard("LaunchCalculator", KeyTable
.XF86XK_Calculator
);
250 addStandard("LaunchCalendar", KeyTable
.XF86XK_Calendar
);
251 addStandard("LaunchMail", KeyTable
.XF86XK_Mail
);
252 addStandard("LaunchMediaPlayer", KeyTable
.XF86XK_AudioMedia
);
253 addStandard("LaunchMusicPlayer", KeyTable
.XF86XK_Music
);
254 addStandard("LaunchMyComputer", KeyTable
.XF86XK_MyComputer
);
255 addStandard("LaunchPhone", KeyTable
.XF86XK_Phone
);
256 addStandard("LaunchScreenSaver", KeyTable
.XF86XK_ScreenSaver
);
257 addStandard("LaunchSpreadsheet", KeyTable
.XF86XK_Excel
);
258 addStandard("LaunchWebBrowser", KeyTable
.XF86XK_WWW
);
259 addStandard("LaunchWebCam", KeyTable
.XF86XK_WebCam
);
260 addStandard("LaunchWordProcessor", KeyTable
.XF86XK_Word
);
262 // 2.15. Browser Keys
264 addStandard("BrowserBack", KeyTable
.XF86XK_Back
);
265 addStandard("BrowserFavorites", KeyTable
.XF86XK_Favorites
);
266 addStandard("BrowserForward", KeyTable
.XF86XK_Forward
);
267 addStandard("BrowserHome", KeyTable
.XF86XK_HomePage
);
268 addStandard("BrowserRefresh", KeyTable
.XF86XK_Refresh
);
269 addStandard("BrowserSearch", KeyTable
.XF86XK_Search
);
270 addStandard("BrowserStop", KeyTable
.XF86XK_Stop
);
272 // 2.16. Mobile Phone Keys
274 // - A whole bunch...
278 // - A whole bunch...
280 // 2.18. Media Controller Keys
282 // - A whole bunch...
283 addStandard("Dimmer", KeyTable
.XF86XK_BrightnessAdjust
);
284 addStandard("MediaAudioTrack", KeyTable
.XF86XK_AudioCycleTrack
);
285 addStandard("RandomToggle", KeyTable
.XF86XK_AudioRandomPlay
);
286 addStandard("SplitScreenToggle", KeyTable
.XF86XK_SplitScreen
);
287 addStandard("Subtitle", KeyTable
.XF86XK_Subtitle
);
288 addStandard("VideoModeNext", KeyTable
.XF86XK_Next_VMode
);
292 addNumpad("=", KeyTable
.XK_equal
, KeyTable
.XK_KP_Equal
);
293 addNumpad("+", KeyTable
.XK_plus
, KeyTable
.XK_KP_Add
);
294 addNumpad("-", KeyTable
.XK_minus
, KeyTable
.XK_KP_Subtract
);
295 addNumpad("*", KeyTable
.XK_asterisk
, KeyTable
.XK_KP_Multiply
);
296 addNumpad("/", KeyTable
.XK_slash
, KeyTable
.XK_KP_Divide
);
297 addNumpad(".", KeyTable
.XK_period
, KeyTable
.XK_KP_Decimal
);
298 addNumpad(",", KeyTable
.XK_comma
, KeyTable
.XK_KP_Separator
);
299 addNumpad("0", KeyTable
.XK_0
, KeyTable
.XK_KP_0
);
300 addNumpad("1", KeyTable
.XK_1
, KeyTable
.XK_KP_1
);
301 addNumpad("2", KeyTable
.XK_2
, KeyTable
.XK_KP_2
);
302 addNumpad("3", KeyTable
.XK_3
, KeyTable
.XK_KP_3
);
303 addNumpad("4", KeyTable
.XK_4
, KeyTable
.XK_KP_4
);
304 addNumpad("5", KeyTable
.XK_5
, KeyTable
.XK_KP_5
);
305 addNumpad("6", KeyTable
.XK_6
, KeyTable
.XK_KP_6
);
306 addNumpad("7", KeyTable
.XK_7
, KeyTable
.XK_KP_7
);
307 addNumpad("8", KeyTable
.XK_8
, KeyTable
.XK_KP_8
);
308 addNumpad("9", KeyTable
.XK_9
, KeyTable
.XK_KP_9
);
310 export default DOMKeyTable
;