Created
October 24, 2016 19:58
-
-
Save yalovek/8a3447eb0e8df44ef4e35b47ed8c2258 to your computer and use it in GitHub Desktop.
Convert keyboard keys from cyrillic to latin
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 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