I need to get a localized character on a keypress event. For example: on the Czech key block I need to get Ε not 5 characters (key code 53) (see Czech keyboard layout ). Is there any other way to get character and not use text input and reading value? In other words, is there a way to get a character from an event object in accordance with the current layout of the user's keyboard?
(added sample code)
<html> <body> <script language="JavaScript"> function onLoad() { console.log(document.getElementById("test")); document.getElementById("test").onkeydown = function(event) { console.log("Code: "+event.keyCode+"; Key: "+String.fromCharCode(event.keyCode)); } } </script> <body onLoad="onLoad();"> <input id="test"> </body> </html>
( online example)
When you try this code and press Ε-key, you will see in the Firebug console "Code: 53; Key: 5". And I need to get "Ε" not "5".
I think this βproblemβ appears on all non-English keyboards.
Honza kuchaΕ
source share