Backspace key of screen keyboard not work

Device Samsung Galaxy Nexus backspace key of screen keyboard not work. In other tested device this key works. Tell me how to fix this?

After viewing the log here is what the problem device:

Code that works with the keyboard here:

        if (GUI.Button(new Rect(480, 304, 1173, 161), characterName, textFieldStyle))
        {
            TouchScreenKeyboard.hideInput = true;
            _keyboard = TouchScreenKeyboard.Open(characterName, TouchScreenKeyboardType.ASCIICapable, false, false);
        }

        if (TouchScreenKeyboard.visible)
        {
            keyboardShown = true;

            characterName = _keyboard.text;

            if (characterName.Length > 13)
            {
                characterName = characterName.Substring(0, 13);
            }
            else
            {
                if (characterName.Length > 0)
                {
                    char[] endChar = characterName.ToCharArray(characterName.Length - 1, 1);

                    if (!((endChar[0] >= 48  endChar[0] <= 57) ||
                        (endChar[0] >= 65  endChar[0] <= 90) ||
                        (endChar[0] >= 97  endChar[0] <= 122)))
                    {
                        characterName = characterName.Remove(characterName.Length - 1, 1);
                    }
                }
            }

            _keyboard.text = characterName;
        }

Tell me how to fix this?

After the test it was found out that the backspace works when the input field of keyboard is displayed. If the input field is hidden: TouchScreenKeyboard.hideInput = true, this key refuses to work. How do I fix this?

Continuing tests found that the backspace does not work on Android 4.1 and above. before showing the keyboard log with the message:

And when you press the backspace:

What’s interesting is that when the textfield of keyboard shows all works. Can someone help me?

This is a know issue with the LatinIME, as of JB it no longer sends key events for non-character keys, like backspace. The only workaround that I know of is to set targetSdkVersion to a version prior to JB (i.e.15).

I am using target sdk api 9 and this is still happening, backspace does not work if hideInput = true. Anything else we can do?

Edit: It works on a Galaxy S3 on 4.1, but not on a Nexus 7-2 on 4.3 or a Nexus7-1 on 4.2.

Read this:

http://code.google.com/p/android/issues/detail?id=62306

You can solve also installing this modified version of the LatinImeGoogle.apk without the delete problem http://d-h.st/0jc

Delete the LatinImeGoogle.apk from /system/app restart your android device and install the downloaded apk as standard apk

This doesn’t seem like a viable option to ask our users to do or can this be automated when our app installs somehow?

I understand. but what i posted, is only to show how is simple solve this problem and the fact that google break thousand of apps without respect the work of thousand of developers. android is an open system ?

My walk around solution is instead of using TouchScreenKeyboard of Unity, I created an android native TextEdit by JNI, and use it to show the keyboard. So far the delete key is still not working(but on any device). what I did is listen to
if (UnityEngine.Input.GetKeyDown(KeyCode.Backspace))
then remove the last char of the string in TextEdit. With this solution we get more control over the behavior of keyboard.

But the weird thing is the delete key is not working on any device for TextEdit that I created programmaly:

// Create and Init
var unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
var activityInstance = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
var focusView = activityInstance.Call<AndroidJavaObject>("getCurrentFocus");
var context = focusView.Call<AndroidJavaObject>("getContext");
mEditText = new AndroidJavaObject("android.widget.EditText", context);
var layoutParams = new AndroidJavaObject("android.view.ViewGroup$LayoutParams", 0, 0);
mEditText.Call("setLayoutParams", layoutParams);
var viewGroup = focusView.Call<AndroidJavaObject>("getParent");
viewGroup.Call("addView", mEditText);

// Open Keyboard
mEditText.Call<bool>("setInputType", TYPE_CLASS_TEXT | TYPE_TEXT_FLAG_NO_SUGGESTIONS);
mEditText.Call<bool>("requestFocus");
inputMethodManager.Call<bool>("showSoftInput", mEditText, 0);

Nothing special if we translate it to java right? But why delete key is not working? And UnityEngine.Input can detect the delete key?
Another weird thing is on Nexus if I use this solution, the keyboard “Dismiss”(looks like “V”) button will make the app no responding. But if I use TouchScreenKeyboard, there is no problem with it. The log shows:

So I’m doubting if there is anything special related to android input in Unity engine layer? Could you please explain more about how the keyboard/input works in Unity Android? Or expose some code about it?

Thank you very much.
Lorry