Skip to content

Instantly share code, notes, and snippets.

@unrevised6419
Created July 11, 2018 14:19
Show Gist options
  • Save unrevised6419/6d823751db89e5e0481b4a976f1c3a95 to your computer and use it in GitHub Desktop.
Save unrevised6419/6d823751db89e5e0481b4a976f1c3a95 to your computer and use it in GitHub Desktop.
Map any keyboard layout and keyboard entry to US layout
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