title: Registering pressed keys with TextInputEditText in Android
body: <p>I'm trying to capture which key is pressed on a TextInputEditText (from Material Design) and although I press any key from keyboard I can't manage to go into onKey method. Could someone help me ?</p>
  
  <pre><code>txtInputApo.setOnKeyListener(new View.OnKeyListener() {
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
              Log.i("onKey","true");
              if(event.getAction() == KeyEvent.ACTION_UP){
                  switch (keyCode){
                      case KeyEvent.KEYCODE_SPACE:
                          String Espaces = txtInputApo.getText().toString().replaceAll(" ", "");
                          txtInputApo.setText(Espaces);
                          txtInputApo.setSelection(Espaces.length());
                          break;
  
                  }
              }
  
              return false;
          }
      });
  </code></pre>
  
  <p>Thanks!</p>