Webpage and keyboard

Source: Internet
Author: User

Starting from the basics. In this tutorial, all IE instances refer to WindowXP + IE 6.0, and all FF instances refer to FF 1.5.
Author Hutia. For more information, see the source.

1. Skip Programming

1.1 Form. The submit shortcut is enter, and the reset shortcut is esc.
1.1.1 in IE, after pressing enter, The onclick event of submit will not be triggered. After pressing esc, The onclick event of reset will be triggered.
1.1.2 is opposite to IE in FF. pressing enter will trigger the onclick event of submit. Pressing esc will not trigger the onclick event of reset.
1.1.3 in form, the time excitation sequence is: onclick => form onsubmit of the submit button

[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
1.2. Accesskey attribute.
1.2.1 note that if the accesskey settings are the same as those in the browser, the menu will take precedence over the menu. The shortcut key for use is alt + set key value
1.2.2 The for Attribute of label works well with accesskey
1.2.3 in IE, The accesskey of The Link object only transfers the focus to the link. It is not equivalent to a click. In FF, it is equivalent to a click. in contrast, the accesskey Effect of input type = checkbox is clicked in IE or FF.
<Input accesskey = "q" value = "press alt + q to focus me. "size =" 100 "> <input accesskey =" a "value =" press alt + a you can focus me. "size =" 100 "type =" codeph "text =" codeph "> Use Label: <label for = "nnn1" accesskey = "d"> A <u> d </u> dress </label> <input id = "nnn1" value = "press alt + d you can focus me. "size =" 100 "> Link: press alt + f to focus me. <input type = checkbox accesskey = "w" href = "# link" onclick = "alert ('checkbox is clicked. '); "/> press alt + w to focus me.
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
2. Then programming is required.

2.1 simple key capture.
2.1.1 events include onkeydown, onkeypress, and onkeyup.
2.1.2 the writing of IE and FF events is different. Learn the following code.
<Pre class = "code" onkeydown = "chkKey (arguments [0]);" onkeyup = "chkKey (arguments [0]); "onkeypress =" chkKey (arguments [0]); "style =" width: 98%; height: 400px; overflow: auto; "> </textarea>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
2.2 because the event will bubble up, you can capture the key on the document to customize the shortcut key.
<Input value = "press ctrl + alt + u to focus on me. "size =" 100 "id =" a1 "> <input value =" press ctrl + alt + 2 to focus on me. "size =" 100 "id =" a2 ">
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
3. To meet the requirements of fmt00, close up this section and hope that fmt00 can be liked. Haha
<Input value = "press a + B + c to focus on me. "size =" 100 "id =" a1 "> <input value =" press d + B + x to focus on me. "size =" 100 "id =" a2 ">
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

Related Article

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.