Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use backspace in Android Chrome #1671

Closed
mustafaakin opened this issue Nov 4, 2013 · 25 comments
Closed

Cannot use backspace in Android Chrome #1671

mustafaakin opened this issue Nov 4, 2013 · 25 comments

Comments

@mustafaakin
Copy link

I cannot use backspace in Android's chrome, it doesn't delete nor move back, any ideas?

@nightwing
Copy link
Member

Which android version and which keyboard do you use?
It works fine on samsung galaxy tab with default, or hackers keyboars

@stefano-maggiolo
Copy link

I just verified the issue on a Nexus 4 with android 4.3 and up-to-date chrome, default keyboard. I tried backspacing many times, and only once it performed a forward-delete, all the other times it did nothing. Typing is also very slow and it lacks the ability to select words on long pressing.

@nightwing
Copy link
Member

Could you please try http://jsbin.com/AgELEqE/2/edit, to see which events chrome fires when backspace is pressed

@timaschew
Copy link

I press delete (backwards) from the end of both strings (abc and efg)

2: keydown      efg    10
2: input        efefg  9
2: input        g      8
2: input        ef     7
1: input        aabc   6
1: keydown      abc    5
1: input        c      4
1: input        ab     3
2: undefined           2
1: undefined           1

tested on nexus 4, Android 4.3 chrome 30

@stefano-maggiolo
Copy link

I'm sorry, I thought the test was about deleting from the HTML source (!) and instead I messed with the test source :)

I tried to restore the original code, and this is what I get on Chrome on Mac when I: load the page, click on the end of the first input, click backspace, click on the end of the second input, click delete (subsequend backspaces just give more pairs keydown+input):

2: input        eg     6
2: keydown      efg    5

1: input        ac     4
1: keydown      abc    3

2: undefined           2
1: undefined           1

I added newlines between my actions.

On Chrome on Android instead, it is like this: the first backspace gives "some" inputs and one keydown, subsequent backspaces just the input

1: input        c      15

1: input        c      14

1: input        c      13

1: input        aabc   12
1: keydown      abc    11
1: input        c      10
1: input        ab     9

2: input        eg     8

2: input        eg     7

2: input        eg     6

2: input        eg     5

2: keydown      efg    4
2: input        ef     3

2: undefined           2
1: undefined           1

A second session:

2: input        eg     18

2: input        eg     17

2: input        eg     16

2: input        efefg  15
2: keydown      efg    14
2: input        g      13
2: input        ef     12

1: input        ac     11

1: input        bc     10

1: input        c      9

1: input        ac     8

1: input        bc     7

1: input        c      6

1: input        ac     5
1: keydown      abc    4
1: input        ab     3

2: undefined           2
1: undefined           1

@nightwing
Copy link
Member

@stefano-maggiolo
Copy link

That works for me. Since I was complaining also about the general slowness on Chrome for Android, this last page you linked feels much faster than another one I had tried.

@nightwing
Copy link
Member

feels much faster than another one I had tried.

Cool! It's a wip branch which will provide better support for android. We still need to cleanup it, and add a way to select words either with long press or tapping with two fingers.

Thanks for the help!

@stefano-maggiolo
Copy link

Awesome, thank you Harutyun!

@yecril71pl
Copy link

Still not fixed (LG-430). Backspace flashes Shift (and does nothing else) and pressing does not select.

@snyderj
Copy link

snyderj commented Jun 21, 2014

Android Nexus 5 running 4.4 - still cannot backspace w/ chrome browser at http://ace.c9.io/#nav=about or https://rawgit.com/ajaxorg/ace/touch_handler/kitchen-sink.html.

@nightwing nightwing reopened this Jun 21, 2014
@nightwing
Copy link
Member

Related chromium bug: https://code.google.com/p/chromium/issues/detail?id=118639.

@bittrance
Copy link

Same problem appears to afflict Firefox on Android. Kitchen-sink and Cloud9 both cosistently ignores backspace from virtual keyboard. Default IME on Nexus 5. Android 4.4.4 build ktu84p. Firefox 32.0.3.

@puzrin
Copy link

puzrin commented Nov 16, 2014

On Nexus 4 with android 4.4.4, backspace works in Chrome 39.0.2171.59, but does not work in Firefox 33.1.

@nightwing
Copy link
Member

this mainly depends on keyboard app.
Good keyboards like https://play.google.com/store/apps/details?id=org.pocketworkstation.pckeyboard&hl=en work ok, see #2185

@nightwing
Copy link
Member

This should be fixed by #3635, please let us know if you still can reproduce this on http://ace.c9.io. Thanks.

@nightwing nightwing moved this from In progress to Done in input-handling Jul 27, 2018
@pascalaschwanden
Copy link

I just checked it on http://ace.c9.io with my android HTC One M9 and it still doesn't work.

Expected result:
hit the backspace button on the keyboard and the character or line will delete

Actual result:
Characters are deleted but line does not wrap around to previous line. empty lines are not deleted when you press the back space key.

@nightwing
Copy link
Member

@pascalaschwanden what keyboard do you use?

@pascalaschwanden
Copy link

The default keyboard on Android 7.0, whatever pops up when I'm in Chrome.

thanks for the fast response.

@pascalaschwanden
Copy link

pascalaschwanden commented Dec 9, 2018

I've been working on some code to fix this problem: but it's a bit of a hack.
The setTimeout part is ugly but will have to do unless there some other event handler that can call this function after an edit has taken place. this kinda works, but still needs more work:

    editor_[id].keyBinding.addKeyboardHandler({
        //  data_before shows contents of text area before the user's keystroke.
        handleKeyboard : function(data, hash, keyString, keyCode, event) {

            //  ace.js bug: Android does not remove the newline upon delete key.
            if( keyCode === 8 ) {

                var before = data.editor.getValue();

                if( Settings.is_mobile ) {
                    setTimeout( function() {

                        var after = editor_[id].getValue();
                        console.log( before + '  ' + after );

                        if( before === after ) {

                            var arr = after.split('');

                            //  Means editor did nothing.  Now delete one value.
                            var cursorPosition = editor_[id].getCursorPosition();

                            var index = editor_[id].session.doc.positionToIndex( cursorPosition, 0 );
                            console.dir(index);
                            console.dir(cursorPosition);
                            console.dir(arr);

                            arr.splice(index, 1);
                            var new_str = arr.join("");

                            editor_[id].setValue( new_str );

                        } else {
                            console.log('diff');
                        }
                    }, 50 );
                }
            }
        }
    });

@nightwing
Copy link
Member

@pascalaschwanden looks like the event for backspace is not fired if cursor is at the beginning of the textarea.
Could you check if https://rawgit.com/ajaxorg/ace/textinput/kitchen-sink.html works?

@pascalaschwanden
Copy link

pascalaschwanden commented Dec 19, 2018 via email

@nightwing
Copy link
Member

Thanks for checking! could you please try this version too https://rawgit.com/ajaxorg/ace/textinput-2/kitchen-sink.html (i am asking because i can't reproduce the issue on my phone).

@pascalaschwanden
Copy link

pascalaschwanden commented Dec 24, 2018 via email

@nightwing
Copy link
Member

Interesting. From your code in #1671 (comment) it seems that backspace key with a correct keycode is fired, but editor doesn't handle it, or somehow reverts the action. Did i understand that example correctly?

Could you please try enabling "Text Input debugger" from the sidebar, pressing backspace several times, and giving me the result from log area
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

9 participants