Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually triggering the iPhone/iPad/iPod keyboard from JavaScript

I am developing an HTML code editor using simple DIV's and capturing events. When I use this on the iPad the keyboard never pops up since i'm not technically in an editable field.

Is there a way to programatically tell the iPad that I need a keybaord?

like image 542
Joe Bienkowski Avatar asked Jan 05 '11 22:01

Joe Bienkowski


People also ask

How do I manually pull up the keyboard on my iPhone?

Go to Settings > Accessibility > Keyboards, tap Full Keyboard Access, then turn on Full Keyboard Access. Control your iPhone using keyboard shortcuts. To customize the keyboard shortcuts, tap Commands.

How do I force the keyboard on my iPad?

You May Need to Tap a Text Field for the Keyboard to Show In that case, you may need to tap on a text input field to make the keyboard appear. If it doesn't appear, then check the other possible solutions listed above, including restarting your iPad to see if that fixes the problem.


1 Answers

If your code is executed via something that was initiated via a user action then it will work.

E.g;

this works (pops keyboard):

<input type='text' id='foo'><div onclick='$("#foo").focus();'>click</div> 

this doesn't work (input gets a border but no keyboard pop):

<input type='text' id='foo'> <script>   window.onload = function() {     $("#foo").focus();   } </script> 
like image 129
Howard Avatar answered Sep 24 '22 06:09

Howard