First, you need to determine whether you want to disable the global control or the specified control. For example, I only need to disable the up and down keys of a text box.
Copy codeThe Code is as follows: 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"); // the Id of the specified control.
If (target. addEventListener) {// bind the listener
Target. addEventListener ("keydown", NoExec, false );
Target. addEventListener ("keypress", NoExec, false );
} Else if (target. attachEvent ){
Target. attachEvent ("onkeydown", NoExec );
}
If it is global, you only need to listen to window. keyDown = function (event !~
Key Value Link corresponding to the keyboard