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?

7
  • 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
    Commented Sep 28, 2014 at 0:16
  • 1
    I have this same issue on android using swype, developing cordova hybrid apps.
    – njtman
    Commented Oct 7, 2014 at 15:32
  • have you tried to set another type or pattern attribute? This might force the browser to use the native keyboard..
    – lloiser
    Commented Nov 19, 2014 at 17:40
  • please check this link if it helps stackoverflow.com/questions/14795944/…
    – kki3908050
    Commented Nov 21, 2014 at 5: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?? Commented Nov 25, 2014 at 6:26

3 Answers 3

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.

3

Would this work?

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

JSFIDDLE

2
  • 1
    @kylex Thanks for the descriptive comment. Commented Oct 8, 2014 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
    Commented Oct 8, 2014 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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.