Custom Keyboard input filter in Android for double tap space

1.4k Views Asked by At

I have a custom filter for an Android app

public static InputFilter alphaNumericFilter = new InputFilter()
{

    public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend)
    {
        for (int i = start; i < end; i++)
        {
            char ch = source.charAt(i);
            //only Latin lowercase uppercase and digit allowed
            if( !((ch>='a' && ch<='z') || (ch>='A' && ch<='Z') || (ch>='0' && ch<='9')))
            {
                return "";
            }
        }

        return null;
    }
};

The problem I am having is that in some devices when you double press space key, it converts it into a ". " (space and dot).

When I run the app, In the filter I am having a space in the first call, then an empty string (means the delete) and in the final call the ". " string.

The result is that when you double press the space bar, It erases two characters from the input text and I just want it to do nothing in that condition.

Is there any way to avoid this? Pls help!

Thank you all.

2

There are 2 best solutions below

0
On

you have to disable auto correct and auto-correction and auto-complete option in your mobile keyboard app.


it worked for me

enter image description here

0
On

just uncheck Double-space full stop in keyboard preferences.