SPB Git forge

spb/admin-ka

Public
41commits 1branches 0releases
172.9 MBsize
maindefault branch
19 days agolast push
JavaScript 65.5% Python 17.8% CSS 13% HTML 3.7%
11.2 KB · 312 lines javascript
Raw Blame History
1/*2 * noVNC: HTML5 VNC client3 * Copyright (C) 2018 The noVNC authors4 * Licensed under MPL 2.0 or any later version (see LICENSE.txt)5 */67import KeyTable from "./keysym.js";89/*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 */1516const DOMKeyTable = {};1718function addStandard(key, standard) {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 + "\"");21    DOMKeyTable[key] = [standard, standard, standard, standard];22}2324function addLeftRight(key, left, right) {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 + "\"");28    DOMKeyTable[key] = [left, left, right, left];29}3031function addNumpad(key, standard, numpad) {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 + "\"");35    DOMKeyTable[key] = [standard, standard, standard, numpad];36}3738// 3.2. Modifier Keys3940addLeftRight("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// - Fn45// - FnLock46addLeftRight("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);50// - Symbol51// - SymbolLock52// - Hyper53// - Super5455// 3.3. Whitespace Keys5657addNumpad("Enter", KeyTable.XK_Return, KeyTable.XK_KP_Enter);58addStandard("Tab", KeyTable.XK_Tab);59addNumpad(" ", KeyTable.XK_space, KeyTable.XK_KP_Space);6061// 3.4. Navigation Keys6263addNumpad("ArrowDown", KeyTable.XK_Down, KeyTable.XK_KP_Down);64addNumpad("ArrowLeft", KeyTable.XK_Left, KeyTable.XK_KP_Left);65addNumpad("ArrowRight", KeyTable.XK_Right, KeyTable.XK_KP_Right);66addNumpad("ArrowUp", KeyTable.XK_Up, KeyTable.XK_KP_Up);67addNumpad("End", KeyTable.XK_End, KeyTable.XK_KP_End);68addNumpad("Home", KeyTable.XK_Home, KeyTable.XK_KP_Home);69addNumpad("PageDown", KeyTable.XK_Next, KeyTable.XK_KP_Next);70addNumpad("PageUp", KeyTable.XK_Prior, KeyTable.XK_KP_Prior);7172// 3.5. Editing Keys7374addStandard("Backspace", KeyTable.XK_BackSpace);75// Browsers send "Clear" for the numpad 5 without NumLock because76// Windows uses VK_Clear for that key. But Unix expects KP_Begin for77// that scenario.78addNumpad("Clear", KeyTable.XK_Clear, KeyTable.XK_KP_Begin);79addStandard("Copy", KeyTable.XF86XK_Copy);80// - CrSel81addStandard("Cut", KeyTable.XF86XK_Cut);82addNumpad("Delete", KeyTable.XK_Delete, KeyTable.XK_KP_Delete);83// - EraseEof84// - ExSel85addNumpad("Insert", KeyTable.XK_Insert, KeyTable.XK_KP_Insert);86addStandard("Paste", KeyTable.XF86XK_Paste);87addStandard("Redo", KeyTable.XK_Redo);88addStandard("Undo", KeyTable.XK_Undo);8990// 3.6. UI Keys9192// - Accept93// - Again (could just be XK_Redo)94// - Attn95addStandard("Cancel", KeyTable.XK_Cancel);96addStandard("ContextMenu", KeyTable.XK_Menu);97addStandard("Escape", KeyTable.XK_Escape);98addStandard("Execute", KeyTable.XK_Execute);99addStandard("Find", KeyTable.XK_Find);100addStandard("Help", KeyTable.XK_Help);101addStandard("Pause", KeyTable.XK_Pause);102// - Play103// - Props104addStandard("Select", KeyTable.XK_Select);105addStandard("ZoomIn", KeyTable.XF86XK_ZoomIn);106addStandard("ZoomOut", KeyTable.XF86XK_ZoomOut);107108// 3.7. Device Keys109110addStandard("BrightnessDown", KeyTable.XF86XK_MonBrightnessDown);111addStandard("BrightnessUp", KeyTable.XF86XK_MonBrightnessUp);112addStandard("Eject", KeyTable.XF86XK_Eject);113addStandard("LogOff", KeyTable.XF86XK_LogOff);114addStandard("Power", KeyTable.XF86XK_PowerOff);115addStandard("PowerOff", KeyTable.XF86XK_PowerDown);116addStandard("PrintScreen", KeyTable.XK_Print);117addStandard("Hibernate", KeyTable.XF86XK_Hibernate);118addStandard("Standby", KeyTable.XF86XK_Standby);119addStandard("WakeUp", KeyTable.XF86XK_WakeUp);120121// 3.8. IME and Composition Keys122123addStandard("AllCandidates", KeyTable.XK_MultipleCandidate);124addStandard("Alphanumeric", KeyTable.XK_Eisu_toggle);125addStandard("CodeInput", KeyTable.XK_Codeinput);126addStandard("Compose", KeyTable.XK_Multi_key);127addStandard("Convert", KeyTable.XK_Henkan);128// - Dead129// - FinalMode130addStandard("GroupFirst", KeyTable.XK_ISO_First_Group);131addStandard("GroupLast", KeyTable.XK_ISO_Last_Group);132addStandard("GroupNext", KeyTable.XK_ISO_Next_Group);133addStandard("GroupPrevious", KeyTable.XK_ISO_Prev_Group);134// - ModeChange (XK_Mode_switch is often used for AltGr)135// - NextCandidate136addStandard("NonConvert", KeyTable.XK_Muhenkan);137addStandard("PreviousCandidate", KeyTable.XK_PreviousCandidate);138// - Process139addStandard("SingleCandidate", KeyTable.XK_SingleCandidate);140addStandard("HangulMode", KeyTable.XK_Hangul);141addStandard("HanjaMode", KeyTable.XK_Hangul_Hanja);142addStandard("JunjaMode", KeyTable.XK_Hangul_Jeonja);143addStandard("Eisu", KeyTable.XK_Eisu_toggle);144addStandard("Hankaku", KeyTable.XK_Hankaku);145addStandard("Hiragana", KeyTable.XK_Hiragana);146addStandard("HiraganaKatakana", KeyTable.XK_Hiragana_Katakana);147addStandard("KanaMode", KeyTable.XK_Kana_Shift); // could also be _Kana_Lock148addStandard("KanjiMode", KeyTable.XK_Kanji);149addStandard("Katakana", KeyTable.XK_Katakana);150addStandard("Romaji", KeyTable.XK_Romaji);151addStandard("Zenkaku", KeyTable.XK_Zenkaku);152addStandard("ZenkakuHankaku", KeyTable.XK_Zenkaku_Hankaku);153154// 3.9. General-Purpose Function Keys155156addStandard("F1", KeyTable.XK_F1);157addStandard("F2", KeyTable.XK_F2);158addStandard("F3", KeyTable.XK_F3);159addStandard("F4", KeyTable.XK_F4);160addStandard("F5", KeyTable.XK_F5);161addStandard("F6", KeyTable.XK_F6);162addStandard("F7", KeyTable.XK_F7);163addStandard("F8", KeyTable.XK_F8);164addStandard("F9", KeyTable.XK_F9);165addStandard("F10", KeyTable.XK_F10);166addStandard("F11", KeyTable.XK_F11);167addStandard("F12", KeyTable.XK_F12);168addStandard("F13", KeyTable.XK_F13);169addStandard("F14", KeyTable.XK_F14);170addStandard("F15", KeyTable.XK_F15);171addStandard("F16", KeyTable.XK_F16);172addStandard("F17", KeyTable.XK_F17);173addStandard("F18", KeyTable.XK_F18);174addStandard("F19", KeyTable.XK_F19);175addStandard("F20", KeyTable.XK_F20);176addStandard("F21", KeyTable.XK_F21);177addStandard("F22", KeyTable.XK_F22);178addStandard("F23", KeyTable.XK_F23);179addStandard("F24", KeyTable.XK_F24);180addStandard("F25", KeyTable.XK_F25);181addStandard("F26", KeyTable.XK_F26);182addStandard("F27", KeyTable.XK_F27);183addStandard("F28", KeyTable.XK_F28);184addStandard("F29", KeyTable.XK_F29);185addStandard("F30", KeyTable.XK_F30);186addStandard("F31", KeyTable.XK_F31);187addStandard("F32", KeyTable.XK_F32);188addStandard("F33", KeyTable.XK_F33);189addStandard("F34", KeyTable.XK_F34);190addStandard("F35", KeyTable.XK_F35);191// - Soft1...192193// 3.10. Multimedia Keys194195// - ChannelDown196// - ChannelUp197addStandard("Close", KeyTable.XF86XK_Close);198addStandard("MailForward", KeyTable.XF86XK_MailForward);199addStandard("MailReply", KeyTable.XF86XK_Reply);200addStandard("MailSend", KeyTable.XF86XK_Send);201// - MediaClose202addStandard("MediaFastForward", KeyTable.XF86XK_AudioForward);203addStandard("MediaPause", KeyTable.XF86XK_AudioPause);204addStandard("MediaPlay", KeyTable.XF86XK_AudioPlay);205// - MediaPlayPause206addStandard("MediaRecord", KeyTable.XF86XK_AudioRecord);207addStandard("MediaRewind", KeyTable.XF86XK_AudioRewind);208addStandard("MediaStop", KeyTable.XF86XK_AudioStop);209addStandard("MediaTrackNext", KeyTable.XF86XK_AudioNext);210addStandard("MediaTrackPrevious", KeyTable.XF86XK_AudioPrev);211addStandard("New", KeyTable.XF86XK_New);212addStandard("Open", KeyTable.XF86XK_Open);213addStandard("Print", KeyTable.XK_Print);214addStandard("Save", KeyTable.XF86XK_Save);215addStandard("SpellCheck", KeyTable.XF86XK_Spell);216217// 3.11. Multimedia Numpad Keys218219// - Key11220// - Key12221222// 3.12. Audio Keys223224// - AudioBalanceLeft225// - AudioBalanceRight226// - AudioBassBoostDown227// - AudioBassBoostToggle228// - AudioBassBoostUp229// - AudioFaderFront230// - AudioFaderRear231// - AudioSurroundModeNext232// - AudioTrebleDown233// - AudioTrebleUp234addStandard("AudioVolumeDown", KeyTable.XF86XK_AudioLowerVolume);235addStandard("AudioVolumeUp", KeyTable.XF86XK_AudioRaiseVolume);236addStandard("AudioVolumeMute", KeyTable.XF86XK_AudioMute);237// - MicrophoneToggle238// - MicrophoneVolumeDown239// - MicrophoneVolumeUp240addStandard("MicrophoneVolumeMute", KeyTable.XF86XK_AudioMicMute);241242// 3.13. Speech Keys243244// - SpeechCorrectionList245// - SpeechInputToggle246247// 3.14. Application Keys248249addStandard("LaunchApplication1", KeyTable.XF86XK_MyComputer);250addStandard("LaunchApplication2", KeyTable.XF86XK_Calculator);251addStandard("LaunchCalendar", KeyTable.XF86XK_Calendar);252// - LaunchContacts253addStandard("LaunchMail", KeyTable.XF86XK_Mail);254addStandard("LaunchMediaPlayer", KeyTable.XF86XK_AudioMedia);255addStandard("LaunchMusicPlayer", KeyTable.XF86XK_Music);256addStandard("LaunchPhone", KeyTable.XF86XK_Phone);257addStandard("LaunchScreenSaver", KeyTable.XF86XK_ScreenSaver);258addStandard("LaunchSpreadsheet", KeyTable.XF86XK_Excel);259addStandard("LaunchWebBrowser", KeyTable.XF86XK_WWW);260addStandard("LaunchWebCam", KeyTable.XF86XK_WebCam);261addStandard("LaunchWordProcessor", KeyTable.XF86XK_Word);262263// 3.15. Browser Keys264265addStandard("BrowserBack", KeyTable.XF86XK_Back);266addStandard("BrowserFavorites", KeyTable.XF86XK_Favorites);267addStandard("BrowserForward", KeyTable.XF86XK_Forward);268addStandard("BrowserHome", KeyTable.XF86XK_HomePage);269addStandard("BrowserRefresh", KeyTable.XF86XK_Refresh);270addStandard("BrowserSearch", KeyTable.XF86XK_Search);271addStandard("BrowserStop", KeyTable.XF86XK_Stop);272273// 3.16. Mobile Phone Keys274275// - A whole bunch...276277// 3.17. TV Keys278279// - A whole bunch...280281// 3.18. Media Controller Keys282283// - A whole bunch...284addStandard("Dimmer", KeyTable.XF86XK_BrightnessAdjust);285addStandard("MediaAudioTrack", KeyTable.XF86XK_AudioCycleTrack);286addStandard("RandomToggle", KeyTable.XF86XK_AudioRandomPlay);287addStandard("SplitScreenToggle", KeyTable.XF86XK_SplitScreen);288addStandard("Subtitle", KeyTable.XF86XK_Subtitle);289addStandard("VideoModeNext", KeyTable.XF86XK_Next_VMode);290291// Extra: Numpad292293addNumpad("=", KeyTable.XK_equal, KeyTable.XK_KP_Equal);294addNumpad("+", KeyTable.XK_plus, KeyTable.XK_KP_Add);295addNumpad("-", KeyTable.XK_minus, KeyTable.XK_KP_Subtract);296addNumpad("*", KeyTable.XK_asterisk, KeyTable.XK_KP_Multiply);297addNumpad("/", KeyTable.XK_slash, KeyTable.XK_KP_Divide);298addNumpad(".", KeyTable.XK_period, KeyTable.XK_KP_Decimal);299addNumpad(",", KeyTable.XK_comma, KeyTable.XK_KP_Separator);300addNumpad("0", KeyTable.XK_0, KeyTable.XK_KP_0);301addNumpad("1", KeyTable.XK_1, KeyTable.XK_KP_1);302addNumpad("2", KeyTable.XK_2, KeyTable.XK_KP_2);303addNumpad("3", KeyTable.XK_3, KeyTable.XK_KP_3);304addNumpad("4", KeyTable.XK_4, KeyTable.XK_KP_4);305addNumpad("5", KeyTable.XK_5, KeyTable.XK_KP_5);306addNumpad("6", KeyTable.XK_6, KeyTable.XK_KP_6);307addNumpad("7", KeyTable.XK_7, KeyTable.XK_KP_7);308addNumpad("8", KeyTable.XK_8, KeyTable.XK_KP_8);309addNumpad("9", KeyTable.XK_9, KeyTable.XK_KP_9);310311export default DOMKeyTable;312