M Rijalul Kahfi
M Rijalul Kahfi

Reputation: 1490

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?

Upvotes: 3

Views: 10087

Answers (4)

Kevin
Kevin

Reputation: 179

I have similar problems that you are facing and I somehow managed to stumble on the solution. Apparently, I had setOnKeyListener to 'return true'. After I changed it to 'return false', the phone keyboard works perfect with backspace functioning properly once again on edittext. Hope this helps:

Solution: One of your existing onkeylistener codes contain 'return true'. Rectify it by setting existing code from 'return true' to 'return false'

.setOnKeyListener(new View.OnKeyListener() {
            public boolean onKey(View v, int keyCode, KeyEvent event) {
  ...
  return false;
                }
        });

Upvotes: 0

Irene Maryanne
Irene Maryanne

Reputation: 21

I had this problem too, I solved it by returning false in onKeyListener function. This should execute normal operations on other keys.

.setOnKeyListener(new DialogInterface.OnKeyListener() 
{
     @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) 
     {
        //your workarounds;
        return false;
     }
})

Upvotes: 2

Carl
Carl

Reputation: 15605

There are two known issues affecting KEYCODE_DEL for the default (LatinIME) Google Keyboard that ships with Android: Issues 42904 and 62306.

I have researched this and have devised a workaround, with code, that seems to get around both of these issues. That workaround can be found here:

Android - cannot capture backspace/delete press in soft. keyboard

Upvotes: 0

JonA
JonA

Reputation: 605

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.

Upvotes: 3

Related Questions