首先你要確定你是要停用全域的還是指定控件,如我只要停用一個文字方塊的上下鍵
NoExec = function(event) {
var k = event.which || event.keyCode;
if (k == 13 || k == 38 | | k == 40) {
if ($("#atWinByArea").attr("id")) {
if (event.which) {//火狐
event.preventDefault();
} else {//IE、Chrome
event.returnValue = false;
}
}
}
downAt(event);
}
var 🎜>downAt(event);
}
var 🎜>downAt(event); document.getElementById("saytext"); //指定的的控制項Id
if (target.addEventListener) {//綁定監聽
target.addEventListener("keydown", NoExec, false);
target.addEventListener("keypress", NoExec, false);
} else if (target.attachEvent) {
target.attachEvent("onkeydown", NoExec);
}
如果是全域的就只要監聽window.keyDown = function(event){.....} 一樣一樣的! ~ 鍵盤所對應的key值鏈接