Recently done touch screen version of the project encountered listening input value, using KeyUp, the keyboard on the phone to press the other keys no problem, but the DELETE key is not listening, find the following solution on the Internet.
Search box based on the value of the user input real-time retrieval, in the beginning naturally think of KeyUp, in the pinyin state, what problem is not,
Question 1: switch to the Chinese input method , the problem came out, KeyUp event is not flexible, and later on the internet search, found the idea,
Question 2: When the public platform is developed , when the customer requests the input box, the Clear button appears behind the input box, the contents of the input box is cleared, and the "KeyUp" event is used in the Chinese input method to partially press the KeyUp event.
method One: Mainly to the search box to register the focus event, a time to retrieve the next, post code
$ (function () { $ (' #wd '). Bind (' Focus ', filter_time); }) var str = '; var now = " filter_time = function () { var time = setinterval (filter_staff_from_exist); $ (this). bind (' blur ', function () { clearinterval (time); }); Filter_staff_from_exist = function () {Now = $.trim ($ (' #wd '). Val ()); if (now! = "&& now! = str) { console.log (now); } str = now; }
Method Two: Use the input and PropertyChange events to solve
First judge the browser is not the evil of IE, no way, write something also has ie user var bind_name = ' input '; if (navigator.userAgent.indexOf ("MSIE")! =-1) {bind_name = ' PropertyChange ';} $ (' #inputorp_i '). Bind (Bind_name, function () {$ (' #inputorp_s '). Text ($ (this). Val ());})
Method Two is not suitable for older browsers
jquery Mobile Keyboard KeyUp failure