title: Hide the keyboard when enter button is pressed - Android WebView
body: <p>When the keyboard opens, the <kbd>⏎</kbd> button doesn't do anything when pressed for my number type input field <code>&lt;input name="age" id="age" type="number"&gt;</code> in my index.html page. Is it possible to close/hide this <kbd>⏎</kbd> button when pressed?</p>
  
  <p>I have tried different answers but I couldn't make any of them work. Kindly suggest me what I'm doing wrong.</p>
  
  <p>This is my main activity. I'm using <a href="https://github.com/delight-im/Android-AdvancedWebView" rel="nofollow noreferrer">AdvancedWebView</a> as WebView component.</p>
  
  <pre><code>public class MainActivity extends Activity implements AdvancedWebView.Listener {
  
      private AdvancedWebView mWebView;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          OneSignal.startInit(this)
              .setNotificationOpenedHandler(new ExampleNotificationOpenedHandler())
              .init();
          setContentView(R.layout.activity_main);
  
          mWebView = (AdvancedWebView) findViewById(R.id.webview);
          mWebView.setListener(this, this);
  
          mWebView.loadUrl("file:///android_asset/index.html");
  
          mWebView.setOnTouchListener(new View.OnTouchListener() {
              @Override
              public boolean onTouch(View v, MotionEvent event) {
                  WebView.HitTestResult hr = ((WebView) v).getHitTestResult();
                  int type = hr.getType();
  
                  if (type == WebView.HitTestResult.EDIT_TEXT_TYPE) {
                      InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                      imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
                      return true;
                  }
                  return false;
              }
          });
      }
  }
  </code></pre>
  
  <p>And this is my manifest xml:</p>
  
  <pre><code>&lt;application
     android:allowBackup="true"
     android:icon="@drawable/ic_launcher"
     android:label="@string/app_name"
     android:theme="@style/AppTheme"&gt;
     &lt;activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:launchMode="singleTask"&gt;
        &lt;intent-filter&gt;
           &lt;action android:name="android.intent.action.MAIN" /&gt;
           &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
     &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>