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?
There is no such best practice. Both are used as per the need of your program and as per the convenience of the user. keyup Fires when the user releases a key, after the default action of that key has been performed. keydown Fires when the user depresses a key.
The keydown and keyup events provide a code indicating which key is pressed, while keypress indicates which character was entered. For example, a lowercase "a" will be reported as 65 by keydown and keyup , but as 97 by keypress . An uppercase "A" is reported as 65 by all events.
KeyDown occurs when the user presses a key. KeyUp occurs when the user releases a key.
The keyup event occurs when a keyboard key is released. The keyup() method triggers the keyup event, or attaches a function to run when a keyup event occurs. Tip: Use the event. which property to return which key was pressed.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With