iOS 8 3rd party keyboards don’t register javascript/jQuery keyup, keypress, keydown etc

When using a 3rd party keyboard like Swiftkey javascript events like keypress don’t register. For example Google maps autocomplete won’t work https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete

Seems like an iOS bug but any ideas on how I can get around this?

You can just manually fire keypress events.

$textBox = $('#text_box') // We don't want to search the dom more than we have to.
setInterval(function(){
    $textBox.trigger('keypress')
}, 500)

This is definitely a messy solution, but it should get autocomplete to work, as well as other handlers that wait for keypresses.

Would this work?

jQuery('#text_box').on('input propertychange paste', function() {
    // text has changed...
});

JSFIDDLE

I found a solution using setInterval and the answered method from here Trigger Google Places Autocomplete

setInterval(function() {
if ($('input#mapSearch').is(':focus')) {
google.maps.event.trigger(document.getElementById('mapSearch'), 'focus', {});
}
}, 500);


The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .
Read More:   How to import popper.js?

Similar Posts