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

后端 未结 3 1090
萌比男神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.

提交回复
热议问题