1

I have searched for close to 6 months and I can't get a proper code on how to detect a backspace click in an EditText view.

Using the setOnKeyListener and doing if(event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_DEL) doesn't work for API 14 and above so we can no longer reply on it.

Also I got an answer which seems to work from here but it only works for InputType.TYPE_NULL and I need it to be a rich text editor. And all other answers I got from SO are not reliable.

And again using TextWatcher won't give me what I want, because I'll want to return true in some conditions therefore making the backspace not to delete the character.

I think it's possible to detect backspace click in Android soft keyboard in higher versions of Android, because I see it in the Facebook app. This Link is a 4sec video of how it looks on Facebook, and that's the exact same result I want.

Any idea on how I can get this done?

KANAYO AUGUSTIN UG
  • 2,078
  • 3
  • 17
  • 31

0 Answers0