Created
October 23, 2016 16:49
-
-
Save yalovek/663ffa179809de4fe9f7166772ed918f to your computer and use it in GitHub Desktop.
Convert keyboard keys from latin to cyrillic
This file contains 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 for converting keyboard keys from latin to cyrillic | |
* @param {String} word Word on latin | |
* @return {String} Word converted to cyrillic | |
*/ | |
const convertKeyboardKeysLatinToCyrillic = word => { | |
const keyboardMap = { | |
'a': 'ф', | |
'b': 'и', | |
'c': 'c', | |
'd': 'в', | |
'e': 'у', | |
'f': 'а', | |
'g': 'п', | |
'h': 'р', | |
'i': 'ш', | |
'j': 'о', | |
'k': 'л', | |
'l': 'д', | |
'm': 'ь', | |
'n': 'т', | |
'o': 'щ', | |
'p': 'з', | |
'q': 'й', | |
'r': 'к', | |
's': 'ы', | |
't': 'е', | |
'u': 'г', | |
'v': 'м', | |
'w': 'ц', | |
'x': 'ч', | |
'y': 'н', | |
'z': 'я', | |
',': 'б', | |
'<': 'б', | |
'.': 'ю', | |
'>': 'ю', | |
';': 'ж', | |
':': 'ж', | |
"'": 'э', | |
'"': 'э', | |
'\\': 'ё', | |
'|': 'ё', | |
'[': 'х', | |
'{': 'х', | |
']': 'ъ', | |
'}': 'ъ' | |
}; | |
return word.toLowerCase() | |
.split('') | |
.map(l => keyboardMap[l]) | |
.join(''); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment