0

I am developing a web application for small-screened android devices. My app has some inputs, but it does not need the soft keyboard at all (and this keyboard takes most of my screen, thus hiding important stuff).

How can I set focus to my text inputs, without making soft keyboard appear? Is there any setting in firefox, any app for android, or maybe there is some hack for javascript that will allow me to do that?

PS. The only solution I am currently thinking about, is catching every key that is being pressed on the whole webpage, and reading that as my text input, but that is not the behavior that I would like to have. :/

ojek
  • 8,047
  • 16
  • 65
  • 106
  • Have you tried: http://stackoverflow.com/questions/10940287/html-mobile-forcing-the-soft-keyboard-to-hide ? – PTwr May 30 '14 at 06:45

1 Answers1

1

hi after trying out the onFocus attribute on the input, and then blur() the text input immediately, if you are not satisfied, then after a brief search i got a tutorial to do this just go through it may be it can help you

http://www.sencha.com/forum/archive/index.php/t-141560.html?s=6853848ccba8060cc90a9cacf7f0cb44

you can also call java code from java script

...
WebView webView = (WebView) findViewById(R.id.webview);
webView.addJavascriptInterface(new JavaScriptInterface(this), "Android");

....

public class JavaScriptInterface {
    Context mContext;

    /** Instantiate the interface and set the context */
    JavaScriptInterface(Context c) {
        mContext = c;
    }

    /** Show a toast from the web page */
    public void hideKeyboard() {
        InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
        ...
    }
}

javascript

<script type="text/javascript">
function hideAndroidKeyboard() {
    Android.hideKeyboard();
}
</script>

Things to watch out for :

Javascript to Native Java will not work on Simulator versions 2.3+. https://code.google.com/p/android/issues/detail?id=12987

here are some links that can help you

keyboard hide input (position:fixed; bottom:0;) with phonegap on android

https://github.com/phonegap/phonegap/wiki/How-to-show-and-hide-soft-keyboard-in-Android

referred from:How can I hide the Android keyboard using JavaScript?

Community
  • 1
  • 1
Bharadwaja Bapatla
  • 3,141
  • 1
  • 11
  • 13