Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Any way to hide the keyboard programmatically?

I have a search field for my iPad app, and when the user begins typing in it, a list of suggestions pops up in a popover (similar to the Google search box in the Safari app). I want to blur the search field and hide the keyboard once the user taps on a suggestion, however, I can't figure out how to do it. Does anyone know?

— asked June 3rd 2010 by Bill Labus
  • hide
  • ipad
  • keyboard
  • textfield
0 Comments

4 Answers

  • Accepted Answer

    textField.blur()

    — answered June 3rd 2010 by Damien Elmes
    permalink
    2 Comments
    • Wow, can't believe I missed that. Thanks!

      — commented June 4th 2010 by Bill Labus
    • does not work in 3.5.0 GA

      — commented April 13th 2015 by Farhad Hossain
  • I know that is a 2 years ago thread, but maybe anyone still looking for a solution for Android (like me!).
    In iPhone I do textfield.blur(); and it works fine, but not in Android.

    Anyone knows how to hide the keyboard in Android?, if I open a window that has a textfield and a tableview. When I open the window I don't want to see the keyboad until the user clicks the textfield.

    Thanks!

    — answered February 26th 2012 by Beto Garcia
    permalink
    5 Comments
    • I finally found a solution!

      I don't know if it's the best way but it works for me!

      Here is the code:

      var textFocusFirstTime = true;
      
      text.addEventListener('focus', function(e){
          if (textFocusFirstTime){
              text.blur();
              textFocusFirstTime = false;
          }
      });
      

      — commented February 26th 2012 by Beto Garcia
    • Beto Garcia, you're the best! :)

      — commented June 20th 2012 by Aziz Hasan
    • but unfortunately, doesn't work all the time, only sometimes!

      — commented June 26th 2012 by Aziz Hasan
    • This works for Android version 3.2. Tested!!! Thanks!!!

      — commented May 22nd 2013 by Jose Ramirez
    • worked wonderfully on Android 4.1.2

      — commented October 17th 2013 by william frazier
  • You can try with Ti.UI.Android.hideSoftKeyboard()

    — answered September 5th 2012 by Alessandro Lanza
    permalink
    1 Comment
    • While this works for Android, the initial question was for iOS.

      — commented September 7th 2012 by Jean-Rene Auger
  • While this works for Android, the initial question was for iOS.

    — answered September 7th 2012 by Jean-Rene Auger
    permalink
    1 Comment
    • Sorry, misread the initial question.

      — commented April 13th 2015 by Jean-Rene Auger
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.