首页 > 前端特效js代码大全 > js控制键盘码 js获取键盘事件 js键盘各键对应的代码

js控制键盘码 js获取键盘事件 js键盘各键对应的代码

发布-网页培训班 | 浏览量-

 简介:

js获取键盘按键的键码event.keyCode,记录-方便查找。
 
1、键盘各按键对应的数字 
keycode 8 = BackSpace keycode 9 = Tab keycode 12 = Clear
keycode 13 = Enter keycode 16 = Shift keycode 17 = Control
keycode 18 = Alt keycode 19 = Pause keycode 20 = CapsLock
keycode 27 = Escape keycode 32 = Space keycode 33 = Prior
keycode 34 = Next keycode 35 = End keycode 36 = Home
keycode 37 = Left keycode 38 = Up keycode 39 = Right
keycode 40 = Down keycode 41 = Select keycode 42 = Print
keycode 43 = Execute keycode 45 = Insert keycode 46 = Delete
keycode 47 = Help keycode 48 = 0 keycode 49 = 1
keycode 50 = 2 keycode 51 = 3 keycode 52 = 4
keycode 53 = 5 keycode 54 = 6 keycode 55 = 7
keycode 56 = 8 keycode 57 = 9 keycode 65 = A
keycode 66 = B keycode 67 = C keycode 68 = D
keycode 69 = E keycode 70 = F keycode 71 = G
keycode 72 = H keycode 73 = I keycode 74 = J
keycode 75 = K keycode 76 = L keycode 77 = M
keycode 78 = N keycode 79 = O keycode 80 = P
keycode 81 = Q keycode 82 = R keycode 83 = S
keycode 84 = T keycode 85 = U keycode 86 = V
keycode 87 = W keycode 88 = X keycode 89 = Y
keycode 90 = Z keycode 112 = F1 keycode 113 = F2
keycode 114 = F3 keycode 115 = F4 keycode 116 = F5
keycode 117 = F6 keycode 118 = F7 keycode 119 = F8
keycode 120 = F9 keycode 121 = F10 keycode 122 = F11
keycode 123 = F12

 

2、键盘码使用

2.1、原生js使用

document.onkeyup = function (event) {

    var e = event ? event : window.event;

    if (e.keyCode == 13) {//旧版火狐、Opera请使用e.which

        alert('您按了回车键。');

    }

};

2.2、jQuery使用

$(document).on('keyup',function(event){

    if (event.keyCode == 13) {

        alert('您按了回车键。');

    }

});

 

js数组的操作大全

javascript 刷新页面方法大全

 

js常用正则表达式

原文地址:http://www.35ui.cn/post/20160526108.html

标签js键盘码js

上一条: 德国布鲁诺钢琴怎么样?
下一条: git 获取远程分支 git 获取远程分支代码

  • 作品
  • 素材
  • ued
  • 资源
  • 前端工程师
  • Asp网页培训班
  • jquery培训班
  • 北京网站制作
  • logo设计培训班
  • 做网站常用代码