PhoneGap IOS Keyboard Done Key Event

I'm using JQuery Mobile within a PhoneGap IOS App. I'm currently successfully capturing the IOS Keyboard return within a search key as follows.

JS
function blah()
{
if(window.event.keyCode == 13   )
{ do something }
}

HTML
<input type="search" id="searchBox" value="" onblur="dothis()" data-inline="true"    onKeyPress="blah();" />

I would like to capture the 'Done' key on the keyboard as well. I cant seem to find any information on this.

Thanks.

Answers


Unfortunately, pressing the "Done" key does not fire a keyCode event. So, I can't seem to find a way to detect it either.

I think the only option is to detect the "blur" event on your field. If the event occurs, then fire whatever action you need. Of course, this is only useful if you have a single field. If you have more than one field, using "blur" to be the equivalent of "Go" or "Submit" is useless.

Let us know if you found a better workaround.


I've suggested using the blur event in my original answer. However, I think a better idea is simply to listen for the keyboard hiding - which will happen after the "Done" button is pressed.

window.addEventListener('keyboardDidHide', function () {
  // Describe your logic which will be run each time keyboard is closed.
});

https://github.com/cjpearson/cordova-plugin-keyboard#keyboarddidhide

Also, be sure the deregister this listener after you've done whatever you need to do after the keyboard hides. Otherwise, it will fire every time the keyboard hides in other parts of your app.


Need Your Help

jQuery templating doubt:

jquery template-engine jquery-templates

With reference to jQuery templating, Rick Strahl has an excellent writeup explaining with functionality over here. During the course of explanation he goes on to say that jQuery supports templating...

PHP Mysql - Illegal mix of collations when using CONCAT

mysql mysqli php

Iv'e been trying to concat two columns from my table and perform a LIKE on them

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.