Use JS to set shortcut keys for combination

Source: Internet
Author: User

Use JS to set shortcut keys for combination

The essence of using JS to set shortcut keys is to get the keycode value of the key you want to set, if you want to add ctrl,alt,shift, then added a ctrlkey,altkey,shiftkey to judge, so the key is to get the value of KeyCode.

(1) Set CTRL +enter Commit

if (e.ctrlkey && e.keycode = =) { 2 return submit (); 3}    

(2) Set ALT + arrow key ← Submit

if (e.altkey&& E.keycode = = PNs) {  2 return3}   

(3) Setting SHIFT+F10 submission

if (e.shiftkey&& E.keycode = = PNs) {  2 return submit ();  4}     

(4) Set Enter submit

if (E.keycode = =) {2 return submit (); 3}    

Some common shortcut keys for keycode:

1 KeyCode 8 =BackSpace BackSpace2 KeyCode 9 =tab TAB3 KeyCode 12 =Clear4 KeyCode 13 =Enter5 KeyCode 16 =shift_l6 KeyCode 17 =control_l7 KeyCode 18 =alt_l8 KeyCode 19 =Pause9 KeyCode 20 =Caps_lockTen KeyCode 27 =Escape EscapeKeyCode 32 =Space SpaceKeyCode 33 =PriorKeyCode 34 =NextKeyCode 35 =EndKeyCode 36 =HomeKeyCode 37 = Left38 KeyCode = upKeyCode 39 = RightKeyCode 40 = DownKeyCode 41 =SelectKeyCode 42 =PrintKeyCode 43 =ExecuteKeyCode 45 =InsertKeyCode 46 =DeleteKeyCode = Help

<script type= "Text/javascript" >

Call the Hotkey function when the onkeydown event occurs
$ ("#CarNo"). KeyDown (function (e) {
if (E.keycode = = 13)
{
Alert ("You press keyboard enter.");
}
});

</script>

Use JS to set shortcut keys for combination

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.