Skip to content

Instantly share code, notes, and snippets.

@yalovek
Created October 23, 2016 16:49
Show Gist options
  • Save yalovek/663ffa179809de4fe9f7166772ed918f to your computer and use it in GitHub Desktop.
Save yalovek/663ffa179809de4fe9f7166772ed918f to your computer and use it in GitHub Desktop.
Convert keyboard keys from latin to cyrillic
/**
* 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