2 * Copyright (c) 2015 Sylvain Peyrefitte
4 * This file is part of mstsc.js.
6 * mstsc.js is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code
49 "BracketLeft" : 0x001A,
50 "BracketRight" : 0x001B,
52 "ControlLeft" : 0x001D,
77 "ShiftRight" : 0x0036,
78 "NumpadMultiply" : 0x0037,
93 "ScrollLock" : 0x0046,
97 "NumpadSubtract" : 0x004A,
101 "NumpadAdd" : 0x004E,
106 "NumpadDecimal" : 0x0053,
107 "PrintScreen" : 0x0054,
108 "IntlBackslash" : 0x0056,
111 "NumpadEqual" : 0x0059,
129 "NonConvert" : 0x007B,
131 "NumpadComma" : 0x007E,
132 "MediaTrackPrevious" : 0xE010,
133 "MediaTrackNext" : 0xE019,
134 "NumpadEnter" : 0xE01C,
135 "ControlRight" : 0xE01D,
136 "VolumeMute" : 0xE020,
137 "LaunchApp2" : 0xE021,
138 "MediaPlayPause" : 0xE022,
139 "MediaStop" : 0xE024,
140 "VolumeDown" : 0xE02E,
142 "BrowserHome" : 0xE032,
143 "NumpadDivide" : 0xE035,
144 "PrintScreen" : 0xE037,
151 "ArrowLeft" : 0xE04B,
152 "ArrowRight" : 0xE04D,
154 "ArrowDown" : 0xE050,
160 "ContextMenu" : 0xE05D,
162 "BrowserSearch" : 0xE065,
163 "BrowserFavorites" : 0xE066,
164 "BrowserRefresh" : 0xE067,
165 "BrowserStop" : 0xE068,
166 "BrowserForward" : 0xE069,
167 "BrowserBack" : 0xE06A,
168 "LaunchApp1" : 0xE06B,
169 "LaunchMail" : 0xE06C,
170 "MediaSelect" : 0xE06D
173 var UnicodeToCodeFirefox_FR = {
213 164 : "BracketRight",
230 60 : "IntlBackslash",
257 111 : "NumpadDivide",
258 106 : "NumpadMultiply",
259 109 : "NumpadSubtract",
271 110 : "NumpadDecimal",
278 var UnicodeToCodeChrome_FR = {
318 186 : "BracketRight",
335 60 : "IntlBackslash",
362 111 : "NumpadDivide",
363 106 : "NumpadMultiply",
364 109 : "NumpadSubtract",
376 110 : "NumpadDecimal",
383 var UnicodeToCode_EN = {
423 221 : "BracketRight",
439 220 : "IntlBackslash",
465 111 : "NumpadDivide",
466 106 : "NumpadMultiply",
467 109 : "NumpadSubtract",
480 110 : "NumpadDecimal",
485 var UnicodeToCode = {
487 'fr' : UnicodeToCodeFirefox_FR,
488 'en' : UnicodeToCode_EN
492 'fr' : UnicodeToCodeChrome_FR,
493 'en' : UnicodeToCode_EN
498 * Scancode of keyevent
499 * @param e {keyboardevent}
500 * @return {integer} scancode
502 function scancode (e) {
503 var locale = Mstsc.locale();
504 locale = (['fr', 'en'].indexOf(locale) > 0 && locale) || 'en';
505 return KeyMap[e.code || UnicodeToCode[Mstsc.browser() || 'firefox'][locale][e.keyCode]];
508 Mstsc.scancode = scancode;