How to resolve the onkeyup event not triggered by the Chinese input method?

Source: Internet
Author: User

How to resolve the onkeyup event not triggered by the Chinese input method?

In the past two days, we have implemented a function that requires real-time monitoring of text box input, and encountered the disgusting problem that the Chinese input method could not trigger the onkeyup event.

The specific performance is as follows:

When listening for an input keyup event, when the English input method is used, the keyup event can be used to detect the change in the text box value. However, when the input method becomes Chinese, the input keyup event will not be triggered normally. This is the first method.

<Html> 

As you can see, this method encounters a problem where the keyup event cannot be triggered in Chinese. So I sought a solution. I thought that there seemed to be no such problem in the baidu search bar, so I started to look at baidu's js. Baidu's js is ugly... the method named "Net" is a letter, and it was found that the timeout was used as a timer to regularly monitor the modification of the input box. Not very satisfied with this method. So I continued to look for a better solution, so I found the oninput and onpropertychange events.

Oninput is available under firefox, while onpropertychange is available under ie. There are some differences between the two methods.

Oninput can only detect changes to the value attribute, while onpropertychange can detect changes to all attributes containing the value. So I started to change it to that.

<Html> 

The problem is solved.


The onkeyup event obtains the input value.

This is a box thinking, and there is a database matching. Automatically match with encapsulated classes.

In javascript, The onkeydown and onkeyup events are not triggered to death.

Which browser is used? The onkeydown of opera may be faulty.
I don't know what functions the landlord will ultimately implement, but the keydown event varies greatly from browser to browser. I suggest you investigate the performance of different browsers.

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.