1

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?

2 Answers 2

1

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.

0

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

1
  • Do you need BOTH plugins (the Cordova & the Ionic one)? Or just the Ionic one?
    – andrewf
    Jan 9, 2018 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.