23

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?

kylex
  • 14,178
  • 33
  • 114
  • 175
adamwjohnson5
  • 663
  • 7
  • 11
  • I have the same issue. I develop myself a tiny keyboard just to check and there is still the same issue. I think it's because ios8 is young. – ababab5 Sep 28 '14 at 00:16
  • 1
    I have this same issue on android using swype, developing cordova hybrid apps. – njtman Oct 07 '14 at 15:32
  • have you tried to set another `type` or `pattern` attribute? This might force the browser to use the native keyboard.. – lloiser Nov 19 '14 at 17:40
  • please check this link if it helps http://stackoverflow.com/questions/14795944/jquery-click-events-not-working-in-ios – kki3908050 Nov 21 '14 at 05:25
  • Did you report it to Apple!, Even I came come across this strange bug today morning. wasted 4-5 hours fighting with this. I am developing PhoneGap app for all platforms, would it be a issue if they use third party keyboard?? – Ajay Suwalka Nov 25 '14 at 06:26
  • Did you ever find a solution to this? Facebook seems to have solved it somehow: When commenting the 'Post' button would be greyed out before but nowadays it activates just fine even with 3rd party keyboards. – Rick Nov 27 '14 at 13:43
  • Same issue here... tried it using SwiftKey 3rdParty Keyboard – Adro Jan 14 '15 at 07:49

3 Answers3

4

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.

Raphael Serota
  • 2,157
  • 10
  • 17
3

Would this work?

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

JSFIDDLE

Pedro Estrada
  • 2,384
  • 2
  • 16
  • 24
  • 1
    @kylex Thanks for the descriptive comment. – Pedro Estrada Oct 08 '14 at 14:40
  • Sorry, it doesn't work with 3rd party keyboards. When typing in using swype (for example), the action is never triggered. It's not until we lose focus on the box that we the change is registered. – kylex Oct 08 '14 at 17:07
1

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);
Community
  • 1
  • 1
adamwjohnson5
  • 663
  • 7
  • 11