JS的中文输入法下KeyDown()的keyCode值总为229

 $(document).keydown(function (e) {
            var currKey = 0, CapsLock = 0, e = e || event;
            theKey = e.keyCode || e.which || e.charCode;
            var tdate = new Date();
            var ttime = tdate.getTime();  //整体毫秒数
            keystring += "(tool:key,Action:keydown,value:" + String.fromCharCode(theKey) + ",time:" + ttime + "),";
        });
        $(document).keyup(function (e) {
            var currKey = 0, CapsLock = 0, e = e || event;
            theKey = e.keyCode || e.which || e.charCode;
            var tdate = new Date();
            var ttime = tdate.getTime();
            keystring += "(tool:key,Action:keyup,value:" + String.fromCharCode(theKey) + ",time:" + ttime + "),"
        });

在获得键盘keydown和keyup时,keyup获得的数据正常,而keydown却一直是229,这是因为中文输入法会转换,目前还不是很清楚,先记下来,查找到结果后再补充

转载于:https://my.oschina.net/ZoeyZhong/blog/1836536

你可能感兴趣的:(JS的中文输入法下KeyDown()的keyCode值总为229)