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

Android Chrome Backspace and Enter do not fire keydown events #2234

Closed
colelawrence opened this issue Feb 7, 2014 · 12 comments
Closed

Android Chrome Backspace and Enter do not fire keydown events #2234

colelawrence opened this issue Feb 7, 2014 · 12 comments
Labels

Comments

@colelawrence
Copy link
Contributor

The only way Backspace works is when your .CodeMirror textarea:focus has a non-empty value and it still doesn't fire a keypress event it fires an input event.

So when you begin typing, CodeMirror shows your current typing from the textarea (textarea has value), allowing you to back space. But once the <textarea>.value is empty you can't make any backspaces because no events are fired. Whenever you move your cursor to another location, the text area is reset: value=""

Is there any way that the textarea can hold a portion of the document where ever your cursor is or is re-located? Or are there any tips on how this can be done efficiently?

This applies to v3 and v4

@colelawrence
Copy link
Contributor Author

I think the answer to whether this is practical/possible is on these lines:
https://github.com/marijnh/CodeMirror/blob/master/lib/codemirror.js#L1484

@marijnh
Copy link
Member

marijnh commented Feb 7, 2014

See the discussion (near the end) in #1196. I tried something like this, and was told it didn't work.

@colelawrence
Copy link
Contributor Author

What if the textarea always had a single space value " " with the cursor after it and we just listened for event changes? Can I immediately clear input and never actually show the textarea value? It shouldn't cause too many problems considering that selection doesn't work at all for mobile devices anyway.

Is that the same concept used for that last attempt: 532c8f3 ?

@marijnh
Copy link
Member

marijnh commented Feb 7, 2014

Yes. You can check out commit 3eef299 and experiment with that, it implements pretty much what you describe (always putting an underscore character at the start of the textarea).

@marijnh
Copy link
Member

marijnh commented Feb 7, 2014

(To clarify, I mean the commit I linked is the last one that has the hack in it, the commit after it reverts it.)

@colelawrence
Copy link
Contributor Author

Did you edit which commit that was?

I found what you were talking about here: 3c3003c

It works for the first time you backspace on Android Chrome, but then obviously the textarea is empty again.

I tried a couple things also, and came to realize that you will need to reset that '_' part of the textarea and prevInput upon every backspace (Also I think I saw backspacing over newlines showing a different behaviour).

@marijnh
Copy link
Member

marijnh commented Oct 20, 2014

Is this still happening in recent Android versions?

@colelawrence
Copy link
Contributor Author

I can check right now.
On Oct 20, 2014 11:09 AM, "Marijn Haverbeke" notifications@github.com
wrote:

Is this still happening in recent Android versions?


Reply to this email directly or view it on GitHub
#2234 (comment)
.

@colelawrence
Copy link
Contributor Author

Yes, this is still a relevant bug tested on v4.6 from http://codemirror.net
(20/10/14)

The issue as researched before, lies in the fact that an invisible
textinput appears where your cursor is for typing, but Android does not
fire backspace keyevents when you change the text input.

This means that as you type the characters you type are inserted into the
invisible text input (intended) but backspacing the text input more than
what you typed when that input was created, does not delete previous text.

It was discussed that this might be solved by initiallizing the input with
a single space that could be backspaced, but I think I remember there being
complex problems behind this solution.
On Oct 20, 2014 11:09 AM, "Marijn Haverbeke" notifications@github.com
wrote:

Is this still happening in recent Android versions?


Reply to this email directly or view it on GitHub
#2234 (comment)
.

@azumbrunnen
Copy link

hey guys! any workaround for this for contentEditable? Seems like there is no way any text editor is going to support Android with this mess right?

@marijnh
Copy link
Member

marijnh commented Feb 24, 2015

This problem is solved for Chrome in the current mobile code. (Though Firefox Android still has a similar issue - #3102)

@marijnh marijnh closed this as completed Feb 24, 2015
@colelawrence
Copy link
Contributor Author

Awesome! Thanks!
On Feb 24, 2015 7:40 AM, "Marijn Haverbeke" notifications@github.com
wrote:

Closed #2234 #2234.


Reply to this email directly or view it on GitHub
#2234 (comment).

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

No branches or pull requests

3 participants