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
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn