keycode对应主要键的关系

65-90  Aa-Zz

192  `~

46  delete del

48-57  0) 1! 2@ 3# 4$ 5% 6^ 7& 8* 9(

186-191 ;: += ,< -_ .> /?

219-222 [{ \| ]} '"

32 空格

8 退格

13 回车功能键

27 esc功能键

=================主键盘区域输入符//出自http://www.cnblogs.com/ahjesus 尊重作者辛苦劳动成果,转载请注明出处,谢谢!

 

 

96-105 0-9

13 回车功能键

106 *

107 +

109 -

110 .

111 /

==================小键盘区域输入符//出自http://www.cnblogs.com/ahjesus 尊重作者辛苦劳动成果,转载请注明出处,谢谢!

 

总结:

8
13
27
32//出自http://www.cnblogs.com/ahjesus 尊重作者辛苦劳动成果,转载请注明出处,谢谢!
46
48-57
65-90
96-107
109-111
186-192
219-222

用法示例JS:

        $(editorDom).keydown(function (e) {
            var code;
            if (!e) {
                var e = window.event;
            }
            if (e.keyCode) {
                code = e.keyCode;
            }
            else if (e.which) {
                code = e.which;
            }
            if (e.ctrlKey && code == 88 || e.ctrlKey && code == 86) {
                return;
            }//出自http://www.cnblogs.com/ahjesus 尊重作者辛苦劳动成果,转载请注明出处,谢谢!
            if (code == 8 || code == 13 || code == 32 || code == 46 || (code >= 48 && code <= 57) || (code >= 65 && code <= 90) || (code >= 96 && code <= 107) || (code >= 109 && code <= 111) || (code >= 186 && code <= 192) || (code >= 219 && code <= 222)) {
                var deviant = 0;
                if (code == 8) {
                    deviant = -deviant;
                }
                _this.Func_saveErrorPoints(editorDom);
                //_this.Func_disposeErrorPoints(p_errorsArr, deviant);
            }
        });

 

转载于:https://www.cnblogs.com/ahjesus/archive/2012/11/15/2771687.html

你可能感兴趣的:(keycode对应主要键的关系)