3

Is it possible to show/hide the soft keyboard programmatically for Cordova/Phonegap?

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
ping94
  • 67
  • 1
  • 1
  • 7

4 Answers4

4

If the plugin is not working for you, maybe you can play with jquery .focus() and .blur() to show/hide the keyboard.

For example, the keyboard will show when an input is on focus, and to lose the focus you can call blur, and the keyboard will hide.

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Pablo
  • 63
  • 9
2

The keyboard shows and hides itself based on input focus, in jQuery ...

// Show keyboard:
jQuery('#some-input-id').focus();

// hide keyboard:
jQuery('input, textarea').blur();

No plugin required.

ekerner
  • 5,650
  • 1
  • 37
  • 31
1

You can use this plugin https://github.com/ionic-team/ionic-plugin-keyboard

This plugin has two methods

cordova.plugins.Keyboard.show
cordova.plugins.Keyboard.close
PraveenKumar
  • 1,851
  • 12
  • 18
  • After I use the plugin, it shows the error -> Property "plugin" does not exist on type "cordova" when I try to use that two methods. – ping94 Aug 11 '17 at 10:36
  • No. I need to access Apache Cordova plugins by using Typescript – ping94 Aug 11 '17 at 10:53
  • Actually I found this plugin https://github.com/amscomp/cordova-plugin-keyboard, but not able to use the method inside. – ping94 Aug 11 '17 at 10:55
  • Useful link https://stackoverflow.com/questions/23477386/cordova-3-4-detect-keyboard-event – PraveenKumar Aug 11 '17 at 11:05
-1

If you aren't using ionic, you may have luck with this plugin. The Keyboard object is attached to the window, so the API is a little different.

window.Keyboard.show();
window.Keyboard.hide();

It's also worth noting that on iOS only the hide method works. There is no way to manually open the keyboard without having a focused input.

Connor Pearson
  • 63,902
  • 28
  • 145
  • 142