AL-zami
AL-zami

Reputation: 9076

had to keep caps lock on for alerting unicode character

Here i want to alert a bengali letter on pressing 'a' button.But for this i had to keep caps lock on.I never worked on unicode characters.Any particular reason for this situation?How i can solve this problem?

var letter={
   '65':2438
}
 document.body.addEventListener('keypress',function(e){
                                  alert(String.fromCharCode(letter[e.keyCode]));
                                  });

enter image description here

Upvotes: 0

Views: 130

Answers (1)

RAM
RAM

Reputation: 2419

See the difference between small 'a' and capital 'A', both of which have respective ASCII values 97 and 65.

For capital letter 'A' (ASCII value 65)

var letter={ '65':2438 } 
document.body.addEventListener('keypress',function(e){     
    alert(String.fromCharCode(letter[e.keyCode])); 
});

For small letter 'a' (ASCII value 97)

var letter={ '97':2438 } 
document.body.addEventListener('keypress',function(e){     
    alert(String.fromCharCode(letter[e.keyCode])); 
});

Upvotes: 1

Related Questions