Welcome!

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

Reply
Contributor
awjenning
Posts: 38
Registered: ‎08-06-2011
My Device: PlayBook
Accepted Solution

Close keyboard when return key pressed

Hello All,

 

I am developing a WebWorks application for PlayBook. I have a page that implements a search feature. At the top of the page is an <input type="search"..> textbox. Next to that is a search button. If the users types search keywords and pressed the button the PlayBook keyboard closes. However if they press the 'return' button on the keyboard it does not close. How can I make the keyboard close when 'return' is pressed?

 

Thanks!!!

Developer
praveen_rajan
Posts: 163
Registered: ‎05-06-2011
My Device: Playbook

Re: Close keyboard when return key pressed

A few questions. Does this page have a HTML form tag? If so, on clicking the return key does the page reloads or nothing happens? What is the desired effect after clicking the search button?

 

The keyboard disappears on clicking the button since the textbox is no longer having focus. If your page has a HTML form tag. Please try the following. I've not tested this but. I've wrote this assuming jquery library is used.

 

<script type="text/javascript">
function cancelKeyPad() {
 $('#search').blur();
 return false;
}
</script>

<form action="#" onsubmit="cancelKeyPad();">
 <input type="text" id="search" />
</form>

 

Contributor
awjenning
Posts: 38
Registered: ‎08-06-2011
My Device: PlayBook

Re: Close keyboard when return key pressed

Praveen,

 

This worked like a charm!  Thanks so much.