jquery - keyup not working on Chrome on Android -
i using bootstrap typeahead.
it depends on jquery code work:
el.on('keyup', dosomething() )
on chrome on windows works fine. on chrome on android doesn't. keyup event never fired. element bound has focus.
this appears recent development.
chrome 28.0.1500.64 android 4.1.2 sgp321 build/10.1.1.a.1.307
thanks
--justin wyllie
i came across same problem earlier today. how can android chrome not support these key events! assume you've found workaround now, here's fix came now.
function newkeyupdown(originalfunction, eventtype) { return function() { if ("ontouchstart" in document.documentelement) { // if it's touch device, or test here android chrome var $element = $(this), $input = null; if (/input/i.test($element.prop('tagname'))) $input = $element; else if ($('input', $element).size() > 0) $input = $($('input', $element).get(0)); if ($input) { var currentval = $input.val(), checkinterval = null; $input.focus(function(e) { clearinterval(checkinterval); checkinterval = setinterval(function() { if ($input.val() != currentval) { var event = jquery.event(eventtype); currentval = $input.val(); event.which = event.keycode = (currentval && currentval.length > 0) ? currentval.charcodeat(currentval.length - 1) : ''; $input.trigger(event); } }, 30); }); $input.blur(function() { clearinterval(checkinterval); }); } } return originalfunction.apply(this, arguments); } } $.fn.keyup = newkeyupdown($.fn.keyup, 'keyup'); $.fn.keydown = newkeyupdown($.fn.keydown, 'keydown');
Comments
Post a Comment