Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android shift key listener

Tags:

android

I need to know when the user hits the Shift key (Soft Keyboard) in my EditText. currently, I'm using an addTextChangedListener, but it isn't called when the Shift key is pressed (though it is when any other key is pressed)

What can I do to know when the user hits the Shift key?

Thanks,

Mat

like image 601
Digital Hazard Avatar asked Jan 18 '23 12:01

Digital Hazard


1 Answers

You have to use View.OnKeyListener

edit1.setOnKeyListener(new View.OnKeyListener() {
 @Override
 public boolean onKey(View v, int keyCode, KeyEvent event) {
    if(event.isShiftPressed())
      {

       }
    return false;
  }
});
like image 90
KV Prajapati Avatar answered Jan 29 '23 13:01

KV Prajapati