How to listen the keypress in the soft keyboard?

前端 未结 4 1312
耶瑟儿~
耶瑟儿~ 2020-12-06 18:11

I need a listener to identify the keypress in the soft keyboard/on screen keyboard.

I tried with addtextchangelistener textwatcher but this one give the good result

4条回答
  •  无人及你
    2020-12-06 18:41

    see this keyevent and use following code to identify which key is pressed by Users.

      @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) 
        {
             // Do Code here
        }
    else if(keyCode == KeyEvent.KEYCODE_0) 
       {
    
       }
    else if(keyCode == KeyEvent.KEYCODE_1) 
       {
    
       }
    return super.onKeyDown(keyCode, event); }
    

提交回复
热议问题