In keydown get charecter event in another language

I am using the keydown event in jquery, but the problem is inactive for the input language. It cannot determine input in English or Hebrew or Arabic ...? it returns only keycode, and I cannot get the character.

Is there any solution?

+5
source share
1 answer

To determine the actual character, you should use keypress instead keydown. While it keydownprovides you with key code, keypressindicates the character that was entered by the user.

, , keydown , keypress.

keypress:

<body>
<form>
  <input id="target" type="text" />
</form>

<script src="http://api.jquery.com/scripts/events.js"></script>
<script>
  $("#target").keypress(function(event) {
    var charCode = event.which; // charCode will contain the code of the character inputted
    var theChar = String.fromCharCode(charCode); // theChar will contain the actual character
  });
</script>
</body>
+5

All Articles