github.com/rajveermalviya/gamen@v0.1.2-0.20220930195403-9be15877c1aa/internal/web/keycodes.go (about) 1 //go:build js 2 3 package web 4 5 import ( 6 "github.com/rajveermalviya/gamen/events" 7 ) 8 9 func mapKeyCode(code string) (events.VirtualKey, bool) { 10 switch code { 11 // case "": 12 // return events.VirtualKeyCancel, true 13 case "Help": 14 return events.VirtualKeyHelp, true 15 case "Backspace": 16 return events.VirtualKeyBackSpace, true 17 case "Tab": 18 return events.VirtualKeyTab, true 19 // case "": 20 // return events.VirtualKeyClear, true 21 case "Enter": 22 return events.VirtualKeyReturn, true 23 case "ShiftLeft": 24 return events.VirtualKeyLShift, true 25 case "ShiftRight": 26 return events.VirtualKeyRShift, true 27 case "ControlLeft": 28 return events.VirtualKeyLControl, true 29 case "ControlRight": 30 return events.VirtualKeyRControl, true 31 case "AltLeft": 32 return events.VirtualKeyLAlt, true 33 case "AltRight": 34 return events.VirtualKeyRAlt, true 35 case "Pause": 36 return events.VirtualKeyPause, true 37 case "CapsLock": 38 return events.VirtualKeyCapsLock, true 39 case "KanaMode": 40 return events.VirtualKeyKana, true 41 // case "": 42 // return events.VirtualKeyJunja, true 43 // case "": 44 // return events.VirtualKeyFinal, true 45 // case "": 46 // return events.VirtualKeyKanji, true 47 case "Escape": 48 return events.VirtualKeyEscape, true 49 case "Convert": 50 return events.VirtualKeyConvert, true 51 case "NonConvert": 52 return events.VirtualKeyNonconvert, true 53 // case "": 54 // return events.VirtualKeyAccept, true 55 // case "": 56 // return events.VirtualKeyModechange, true 57 case "Space": 58 return events.VirtualKeySpace, true 59 case "PageUp": 60 return events.VirtualKeyPageUp, true 61 case "PageDown": 62 return events.VirtualKeyPageDown, true 63 case "End": 64 return events.VirtualKeyEnd, true 65 case "Home": 66 return events.VirtualKeyHome, true 67 case "ArrowLeft": 68 return events.VirtualKeyLeft, true 69 case "ArrowUp": 70 return events.VirtualKeyUp, true 71 case "ArrowRight": 72 return events.VirtualKeyRight, true 73 case "ArrowDown": 74 return events.VirtualKeyDown, true 75 case "Select": 76 return events.VirtualKeySelect, true 77 // case "": 78 // return events.VirtualKeyPrint, true 79 // case "": 80 // return events.VirtualKeyExecute, true 81 case "Insert": 82 return events.VirtualKeyInsert, true 83 case "Delete": 84 return events.VirtualKeyDelete, true 85 case "Digit0": 86 return events.VirtualKey0, true 87 case "Digit1": 88 return events.VirtualKey1, true 89 case "Digit2": 90 return events.VirtualKey2, true 91 case "Digit3": 92 return events.VirtualKey3, true 93 case "Digit4": 94 return events.VirtualKey4, true 95 case "Digit5": 96 return events.VirtualKey5, true 97 case "Digit6": 98 return events.VirtualKey6, true 99 case "Digit7": 100 return events.VirtualKey7, true 101 case "Digit8": 102 return events.VirtualKey8, true 103 case "Digit9": 104 return events.VirtualKey9, true 105 case "Semicolon": 106 return events.VirtualKeySemicolon, true 107 case "Equal": 108 return events.VirtualKeyEquals, true 109 case "KeyA": 110 return events.VirtualKeyA, true 111 case "KeyB": 112 return events.VirtualKeyB, true 113 case "KeyC": 114 return events.VirtualKeyC, true 115 case "KeyD": 116 return events.VirtualKeyD, true 117 case "KeyE": 118 return events.VirtualKeyE, true 119 case "KeyF": 120 return events.VirtualKeyF, true 121 case "KeyG": 122 return events.VirtualKeyG, true 123 case "KeyH": 124 return events.VirtualKeyH, true 125 case "KeyI": 126 return events.VirtualKeyI, true 127 case "KeyJ": 128 return events.VirtualKeyJ, true 129 case "KeyK": 130 return events.VirtualKeyK, true 131 case "KeyL": 132 return events.VirtualKeyL, true 133 case "KeyM": 134 return events.VirtualKeyM, true 135 case "KeyN": 136 return events.VirtualKeyN, true 137 case "KeyO": 138 return events.VirtualKeyO, true 139 case "KeyP": 140 return events.VirtualKeyP, true 141 case "KeyQ": 142 return events.VirtualKeyQ, true 143 case "KeyR": 144 return events.VirtualKeyR, true 145 case "KeyS": 146 return events.VirtualKeyS, true 147 case "KeyT": 148 return events.VirtualKeyT, true 149 case "KeyU": 150 return events.VirtualKeyU, true 151 case "KeyV": 152 return events.VirtualKeyV, true 153 case "KeyW": 154 return events.VirtualKeyW, true 155 case "KeyX": 156 return events.VirtualKeyX, true 157 case "KeyY": 158 return events.VirtualKeyY, true 159 case "KeyZ": 160 return events.VirtualKeyZ, true 161 case "OSLeft", "MetaLeft": 162 return events.VirtualKeyLWin, true 163 case "OSRight", "MetaRight": 164 return events.VirtualKeyRWin, true 165 case "ContextMenu": 166 return events.VirtualKeyContextMenu, true 167 case "Sleep": 168 return events.VirtualKeySleep, true 169 case "Numpad0": 170 return events.VirtualKeyNumpad0, true 171 case "Numpad1": 172 return events.VirtualKeyNumpad1, true 173 case "Numpad2": 174 return events.VirtualKeyNumpad2, true 175 case "Numpad3": 176 return events.VirtualKeyNumpad3, true 177 case "Numpad4": 178 return events.VirtualKeyNumpad4, true 179 case "Numpad5": 180 return events.VirtualKeyNumpad5, true 181 case "Numpad6": 182 return events.VirtualKeyNumpad6, true 183 case "Numpad7": 184 return events.VirtualKeyNumpad7, true 185 case "Numpad8": 186 return events.VirtualKeyNumpad8, true 187 case "Numpad9": 188 return events.VirtualKeyNumpad9, true 189 case "NumpadMultiply": 190 return events.VirtualKeyMultiply, true 191 case "NumpadAdd": 192 return events.VirtualKeyAdd, true 193 case "NumpadSubtract": 194 return events.VirtualKeySubtract, true 195 case "NumpadDecimal": 196 return events.VirtualKeyDecimal, true 197 case "NumpadDivide": 198 return events.VirtualKeyDivide, true 199 case "F1": 200 return events.VirtualKeyF1, true 201 case "F2": 202 return events.VirtualKeyF2, true 203 case "F3": 204 return events.VirtualKeyF3, true 205 case "F4": 206 return events.VirtualKeyF4, true 207 case "F5": 208 return events.VirtualKeyF5, true 209 case "F6": 210 return events.VirtualKeyF6, true 211 case "F7": 212 return events.VirtualKeyF7, true 213 case "F8": 214 return events.VirtualKeyF8, true 215 case "F9": 216 return events.VirtualKeyF9, true 217 case "F10": 218 return events.VirtualKeyF10, true 219 case "F11": 220 return events.VirtualKeyF11, true 221 case "F12": 222 return events.VirtualKeyF12, true 223 case "F13": 224 return events.VirtualKeyF13, true 225 case "F14": 226 return events.VirtualKeyF14, true 227 case "F15": 228 return events.VirtualKeyF15, true 229 case "F16": 230 return events.VirtualKeyF16, true 231 case "F17": 232 return events.VirtualKeyF17, true 233 case "F18": 234 return events.VirtualKeyF18, true 235 case "F19": 236 return events.VirtualKeyF19, true 237 case "F20": 238 return events.VirtualKeyF20, true 239 case "F21": 240 return events.VirtualKeyF21, true 241 case "F22": 242 return events.VirtualKeyF22, true 243 case "F23": 244 return events.VirtualKeyF23, true 245 case "F24": 246 return events.VirtualKeyF24, true 247 case "NumLock": 248 return events.VirtualKeyNumLock, true 249 case "ScrollLock": 250 return events.VirtualKeyScrollLock, true 251 case "Minus": 252 return events.VirtualKeyHyphenMinus, true 253 case "AudioVolumeMute", "VolumeMute": 254 return events.VirtualKeyVolumeMute, true 255 case "AudioVolumeDown", "VolumeDown": 256 return events.VirtualKeyVolumeDown, true 257 case "AudioVolumeUp", "VolumeUp": 258 return events.VirtualKeyVolumeUp, true 259 case "Comma": 260 return events.VirtualKeyComma, true 261 case "Period": 262 return events.VirtualKeyPeriod, true 263 case "Slash": 264 return events.VirtualKeySlash, true 265 case "Backquote": 266 return events.VirtualKeyBackQuote, true 267 case "BracketLeft": 268 return events.VirtualKeyOpenBracket, true 269 case "Backslash": 270 return events.VirtualKeyBackSlash, true 271 case "BracketRight": 272 return events.VirtualKeyCloseBracket, true 273 case "Quote": 274 return events.VirtualKeyQuote, true 275 // case "": 276 // return events.VirtualKeyAltgr, true 277 } 278 279 return 0, false 280 }