JS example code for shielding and changing the button Effect
This article mainly describes the sample code for JS to shield the key effect and change the key effect. You can refer to the Code for help.
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;
}
}