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 but it shows the change also when some text is pasted into it.
I need to identify only the key press by the user.
Is there any possible way to detect the key press.
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); }
When handling keyboard events with the KeyEvent class and related APIs, you should expect that such keyboard events come only from a hardware keyboard. You should never rely on receiving key events for any key on a soft input method (an on-screen keyboard).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With