I am struggling a little bit with this implementation. I'm building my first Hello World! android(cordova) application that requires a keyboard to show always and avoid hiding it like when the user clicks the back button or any other input.
Why? basically I don't have any input element in my HTML to trigger a focus & show the keyboard, it's kind of a 'terminal emulator' where the user performs certain commands.
The keyboard wasn't showing at all so I went and I added the following:
Installed Ionic Keyboard plugin
cordova plugin add https://github.com/driftyco/ionic-plugins-keyboard.git
Added a Permission to config.xml
<feature name="Keyboard">
<param name="android-package" value="com.ionic.keyboard.IonicKeyboard" />
<param name="onload" value="true" />
</feature>
In my App module, the following lines :
var myApp = angular.module('myApp', ['ionic']);
myApp.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
window.cordova.plugins.Keyboard.show(); // Show Keyboard on startup
// and here Trigger a show keyboard when hidden
window.addEventListener('native.hidekeyboard', keyboardHideHandler);
function keyboardHideHandler(e){
window.cordova.plugins.Keyboard.show();
}
}
});
});
Now, the above implementation works but I do not think it is elegant to handle it this way and I don't like the feel that the keyboard closes then pops up again.
- Is there an alternative way besides Ionic keyboard's plugin to configure my android app to show keyboard all the time?
- Is this the correct way doing it with Cordova/Ionic frameworks?
Hope I am on the right track.Any hints would be appreciated.
Thank you
Screenshots