Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 988
adamwjohnson5 Avatar asked Sep 28 '14 00:09

adamwjohnson5


People also ask

Should I use Keyup or Keydown?

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.

What is keyup and keydown event in JavaScript?

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.

What is the difference between Keyup and Keydown?

KeyDown occurs when the user presses a key. KeyUp occurs when the user releases a key.

What is Keyup event?

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.


2 Answers

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.

like image 67
Raphael Serota Avatar answered Sep 18 '22 04:09

Raphael Serota


Would this work?

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

JSFIDDLE

like image 24
Pedro Estrada Avatar answered Sep 22 '22 04:09

Pedro Estrada