JS example code for shielding and changing the button Effect

Source: Internet
Author: User

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;

}

}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.