Chrome does not work on Android

I am using bootstrap typeahead.

It depends on this jQuery code:

el.on('keyup', doSomething() ) 

On Chrome on Windows, it works fine. Chrome on Android doesnโ€™t. The keyup event never fires. The element to which it is attached definitely has focus.

This is apparently a recent development.

Chrome 28.0.1500.64 Android 4.1.2 SGP321 Build / 10.1.1.A.1.307

thanks

- Justin Willie

+4
source share
2 answers

Today I ran into this problem. How android chrome does not support these key events! I assume that you have found a workaround by now, but here is the fix that I came up with now.

 function newKeyUpDown(originalFunction, eventType) { return function() { if ("ontouchstart" in document.documentElement) { // if it a touch device, or test here specifically for 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'); 
+3
source

Sorry this is, but keyup / keydown events do not work for Chrome browser on Android. There are other people who have reported this problem ( here and here ) since the last year, but have not yet fixed it. therefore, developers should better avoid using these events until they are fixed.

+1
source

Source: https://habr.com/ru/post/1494527/


All Articles