Skip to content

Instantly share code, notes, and snippets.

@yalovek
Created October 24, 2016 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yalovek/8a3447eb0e8df44ef4e35b47ed8c2258 to your computer and use it in GitHub Desktop.
Save yalovek/8a3447eb0e8df44ef4e35b47ed8c2258 to your computer and use it in GitHub Desktop.
Convert keyboard keys from cyrillic to latin
/**
* Function for converting keyboard keys from cyrillic to latin
* @param {String} word Word on cyrillic
* @return {String} Word converted to latin
*/
const convertKeyboardKeysCyrillicToLatin = 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