Если пользователь вводит Rbtd нужно искать Киев
соответственно я делаю так
var trans=[
["q","w","e","r","t","y","u","i","o","p","[","]","a","s","d","f","g","h","j","k","l",";","'","z","x","c","v","b","n","m",",",".",'Q','W','E','R','T','Y','U','I','O','P','{','}','A','S','D','F','G','H','J','K','L',':','"','Z','X','C','V','B','N','M','<','>'],
["й","ц","у","к","е","н","г","ш","щ","з","х","ъ","ф","ы","в","а","п","р","о","л","д","ж","э","я","ч","с","м","и","т","ь","б","ю",'Й','Ц','У','К','Е','Н','Г','Ш','Щ','З','Х','Ъ','Ф','Ы','В','А','П','Р','О','Л','Д','Ж','Э','Я','Ч','С','М','И','Т','Ь','Б','Ю']
];
document.getElementById('city_form').onkeyup=function(ev){
var val1=String(ev.target.value);
for(var i=0; i<val1.length; i++){
var getIndex=trans[0].indexOf(val1[i]);
if(getIndex!=-1){
val1[i]=trans[1][getIndex];
console.log(val1[i], trans[1][getIndex]);
}
}
};
В консоль выводится
R К
Почему ?