Search code examples
androidandroid-edittextkeylistener

Android. Backspace/delete key not functioning.


When onKeyListener is set Backspace/delete key is not functioning.

I set an OnKeyListener on my EditText. Then default actions of some keys became not functioning. Like DELETE/Backspace. Then I changed to use my own text-deleting function by manipulating the string inside. But it seems to be pretty complex.

I have to get selection, make substring, and so on. Are there other solutions to get the key functioning normally?


Solution

  • It depends on the IME you are using. Some IME implements delete function without sending KEYCODE_DEL. Try other IME than the default.

    For example, if you press DEL button long enough, some IME deletes all text in the edit box. This cannot be done through KEYCODE_DEL.