Tuesday, April 5, 2016

Cordova/PhoneGap force the calling to the virtual keyboard - how to

I've spent some days to search a solution to an issue I have when a input text in my ui needs to show the android virtual keyboard.
The only way I found, is to add a plugin to my cordova-phonegap project via command line interface.
First, ensure you have cordova.js included/imported in your html page.
Move into the project directory and type:
cordova plugin add ionic-plugin-keyboard

the in your code(javascript) when you need call this:
cordova.plugins.Keyboard.show();

...and the virtual keyboard show up.

Note that during development if you are testing your app in the browser, probably you'll be notified by this error:

"Cannot read property 'Keyboard' of undefined"

It's depends by the cordova.js that you have included into the page, but it is imported only when application is built for the devices.
So you will really see it in the device or in device emulator.

It's all.

I try it only in Android. Please notify me(also with a simple comment) if it correctly works on other platforms.

Here you can find some documentation.

Bye...





1 comment:

  1. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.

    ReplyDelete