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

后端 未结 3 1091
萌比男神i
萌比男神i 2021-02-18 13:46

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/map

相关标签:
3条回答
  • 2021-02-18 13:58

    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.

    0 讨论(0)
  • 2021-02-18 13:59

    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);
    
    0 讨论(0)
  • 2021-02-18 14:00

    Would this work?

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

    JSFIDDLE

    0 讨论(0)
提交回复
热议问题