Reputation: 523
I have the next test code:
html:
<html>
<head>
<script src="js/app.js"></script>
<script src="cordova.js"></script>
</head>
<body>
<p><button>Show keyboard</button></p>
<p><input></input></p>
<p><span>?</span></p>
</body>
</html>
and js:
document.addEventListener("deviceready", handler, false);
function handler() {
window.addEventListener('native.keyboardshow', function() {
document.getElementsByTagName("span")[0].innerHTML = "showed";
});
document.getElementsByTagName("button")[0].addEventListener("click", function() {
document.getElementsByTagName("input")[0].focus();
cordova.plugins.Keyboard.show();
});
}
The show()
function works, and I understand that the plugin is available from my app. But when the keyboard is showed nothing occurs: my span
tag doesn't get the "showed"
text.
What is an issue?
Upvotes: 1
Views: 837
Reputation: 337
If you are targeting Android, add <preference name="android-windowSoftInputMode" value="adjustResize" />
to config.xml as noted in this answer: https://stackoverflow.com/a/31683935/5356747
With this preference set keyboard events started to fire in my app.
Upvotes: 1
Reputation: 6662
You probably have added cordova-plugin-keyboard (its events doesn't fire on android. Plus, the name of events are also different).
You need to add ionic-plugin-keyboard:
cordova plugin add ionic-plugin-keyboard --save
Upvotes: 0