JavaScript text box, determine the Enter trigger event compatible Ie&firefox

Source: Internet
Author: User

1.onkeypress&onkeydown differences

The onkeypress event occurs when the user presses and releases any alphanumeric keys. However, the system buttons (for example: arrow keys, function keys) cannot be identified.
The onkeydown event occurs when the user presses any keyboard key, including the system button. The captured keycode do not differentiate between letter sizes, but onkeypress.

IE6 's onkeypress will accept the "carriage return event", and OnKeyDown will not accept
IE8 's onkeypress will not accept the carriage return event, and OnKeyDown will accept

In Firefox, onkeypress and onkeydown All accept the "carriage return event".

function //  var e = e | |  If//13 for carriage return //TO_DO Press ENTER after action  </script> 

In the HTML source code, at the same time use the onkeypress, onkeydown, but said above, Firefox accepts carriage return event, in order to make it run only once, then any one event incoming parameter event, the other one does not pass parameters.

Finally, complete the compatible ie&firefox.

JavaScript text box, determine Enter trigger event compatible Ie&firefox

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.