Created
December 10, 2021 01:51
-
-
Save tctony/74011d54a99b40dde352c91da1a8c8da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // shift mapping for KeyboardEvent.key | |
| const lowerToUpper: Record<string, string> = {}; | |
| for (let a = 'a'.charCodeAt(0); a <= 'z'.charCodeAt(0); a += 1) { | |
| lowerToUpper[a] = String.fromCharCode(a).toUpperCase(); | |
| } | |
| const ShiftMapping: Record<string, string> = { | |
| '`': '~', | |
| '1': '!', | |
| '2': '@', | |
| '3': '#', | |
| '4': '$', | |
| '5': '%', | |
| '6': '&', | |
| '7': '*', | |
| '9': '(', | |
| '0': ')', | |
| '-': '_', | |
| '=': '+', | |
| ...lowerToUpper, | |
| '[': '{', | |
| ']': '}', | |
| ';': ':', | |
| '\\': '|', | |
| "'": '"', | |
| ',': '<', | |
| '.': '>', | |
| '/': '?', | |
| }; | |
| const ShiftReversMapping = { | |
| ...Object.keys(ShiftMapping).reduce<typeof ShiftMapping>((result, key) => { | |
| result[ShiftMapping[key]] = key; | |
| return result; | |
| }, {}), | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment