我正在开发一个javascript键盘,试图让用户输入各种非洲语言.目前,这在IE8和Firefox中运行良好但不是谷歌浏览器,我实际上只是坚持这个.我想要完成的是例如,键入(在我的物理键盘上)' q '(keyCode = 113)并获得' ɛ '(keyCode = 603)作为输出,但目前,我的代码在谷歌浏览器中没有任何作用.我的代码的相关部分如下:
var k_layouts = {};
k_layouts.Akan = {88:390,113:603};//keyCode mappings for Akan language
k_layouts.Ga = {120:596,81:400};//keyCode mappings for Ga language
var current_layout = "";
//function that maps the keyCode of a **typed** key to that of the **expected** key
function map_key_code(keycode){
if(k_layouts[current_layout] && k_layouts[current_layout][keycode])
return k_layouts[current_layout][keycode];
return keycode;
}
//function that actually changes the keyCode of a **typed** key to the **expected** value
function handle_keypress(ev){
var ev = ev || window.event;
if(ev.bubbles != …
Run Code Online (Sandbox Code Playgroud)