This article is mainly on JS shield button effect and change the effect of the sample code for the key, need a friend can come over for reference, hope to help everyone function key F1-F2: 112-123
A-B: 65-90
Number key: 0--57
ESC: 27
Return key: 8
Press Enter: 13
Shift: 16; Ctrl: 17; Alt: 18
Space: 32
Insert: 45; Delete: 46
The Code is as follows:
Function document. onkeydown () {// trigger by pressing enter on the webpage
If (event. keyCode = 13)
{
Document. getElementById ("loginbtn"). click ();
Return false;
}
}
Document. onkeydown = MM_KeyPress;
Function MM_KeyPress (num ){
// Prevents system backspace keys
Var keycode = event. keyCode;
If (keycode = 8) // block the backend key
{
Event. keyCode = 0;
// Event. returnValue = false;
Return;
}
If (keycode> = 112 & keycode <= 123) // mask the f1-12 function key
{
Event. keyCode = 0;
Event. returnValue = false;
Return;
}
}