Created
July 11, 2018 14:19
-
-
Save unrevised6419/6d823751db89e5e0481b4a976f1c3a95 to your computer and use it in GitHub Desktop.
Map any keyboard layout and keyboard entry to US layout
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
function getChar({ code, shiftKey }) { | |
if (code.startsWith('Key')) { | |
return code.replace('Key', '') | |
} | |
if (code.startsWith('Digit')) { | |
return code.replace('Digit', '') | |
} | |
const normal = { | |
'Semicolon': ';' | |
} | |
const shifted = { | |
'Semicolon': ':' | |
} | |
return shiftKey ? shifted[code] : normal[code] | |
} | |
console.log(getChar({ | |
code: 'Semicolon', | |
shiftKey: true | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment