First you have to determine whether you want to disable global or specific controls. For example, I just want to disable the up and down keys of a text box
NoExec = function(event) {
var k = event.which || event.keyCode;
if (k == 13 || k == 38 | | k == 40) {
if ($("#atWinByArea").attr("id")) {
if (event.which) {//Firefox
event.preventDefault();
} else {//IE, Chrome
event.returnValue = false;
}
}
}
downAt(event);
}
var target = document.getElementById("saytext"); //Specified control Id
if (target.addEventListener) {//Binding listener
target.addEventListener("keydown", NoExec, false);
target.addEventListener("keypress", NoExec, false);
} else if (target.attachEvent) {
target.attachEvent("onkeydown", NoExec);
}
If it is global, just listen to window.keyDown = function(event){.....} Same! ~
The key value link corresponding to the keyboard