Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

How to open the virtual keyboard using JavaScript

Heya devs,


I wanted to share the following tip on how to programatically open the virtual keyboard from your WebWorks application.  Depending on the UX you are trying to achieve from within your application, it may be nice to promt your users to complete an input field upon the inial load of your page (e.g. a login screen).


This behavior is achieved by using the focus() JavaScript method, like this:



<title> Browser: Focus </title>
<script type="text/javascript">
   function applyFocus(id)
   function endFocus()
   function startFocus()
   	setTimeout(endFocus, 2000);
<body onload="setTimeout(startFocus, 2000)">
<h1>Browser: Apply Focus</h1>
   After 2 seconds, focus will be applied to the 'Hello World' text field.  
   2 seconds after that, focus will be removed from the text field (and applied to the button).  The net result will be that the user sees the virtual keyboard appear and then disappear.

	<button id="btnApply" onclick="applyFocus('txtText')">Apply Focus --> </button>
	<input type="text" id="txtText" value="Hello World" />
	<button onclick="applyFocus('btnApply')"> <-- Remove Focus </button>


Let me know if you found this helpful.





Follow me on Twitter: @n_adam_stanley
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Regular Contributor
Posts: 82
Registered: ‎11-12-2010
My Device: Android Droid Incredible
My Carrier: Verizion

Re: How to open the virtual keyboard using JavaScript

this is helpful thank you. Also wondering how do you tell the keyboard what type it should display on focusing onto the textfield? I.E. email, pin, url, qwerty....