How to hide Keyboard in Cordova by pressing "Go" or "Done"

Asked

Viewed 608 times

8

I have a form in my app, and I would like that after filling, if the person pressed Ir or Done, the keyboard would disappear.

Has anyone ever been there? Or knows how to solve?

  • 1

    Can’t get the input focus? I believe this will close the keyboard.

  • @Oeslei am actually a native Ios developer, and the q project I’m working on is angular with Cordova.(I’ve never used it before) I’ll try to figure out how to do it, if it works out. Thank you

  • The idea would be to make a button that simply removes the keyboard on the page, and when done successfully, embed that code in the buttons Ir and Done.

2 answers

2

The best way to interact with the keyboard is using the plugin Ionic-plugin-Keyboard.

One of its methods is Cordova.plugins.Keyboard.close() that allows you to close the keyboard.

1

I believe that with the idea of @Eduardocalixto works, but you need to test, of course. But the logic is as follows:

  1. Attach an event to the controller that you want to have this behavior. In agular is something like: ng-keydown="expression", ng-keypress="expression", ng-keyup="expression" I believe that the keypress fits better, being that the value expression will be the function declared in your current $Scope to the element in question.
  2. In the function attaches to the event you make the control if the clicked key is the button you want through the Event.keycode
  3. If the key pressed on the keyboard is the one you want then you call the function @Eduardocalixo quoted above Cordova.plugins.Keyboard.close()

Remembering that you need to have the plugin https://github.com/driftyco/ionic-plugin-keyboard installed for the above method to work. Good luck!.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.