验证码 禁止输入中文

方法一:禁止中文输入法

<input type="text" style="ime-mode:disabled">

方法二:禁止黏贴,禁止拖拽,禁止中文输入法!

这种方法是最强的禁止 中文输入

<input type="text" onpaste="return false" ondragenter="return false" oncontextmenu="return false;" style="ime-mode:disabled"/>

获取键盘按下值

function keyUp(e) {
var currKey = 0, e = e || event;
currKey = e.keyCode || e.which || e.charCode;
var keyName = String.fromCharCode(currKey);
//alert("按键码: " + currKey + " 字符: " + keyName);
}
document.onkeyup = keyUp;

原文地址:https://www.cnblogs.com/louby/p/4958419.html