Issue 184812 in chromium: Detect backspace keydown event at the beginning of text input

801 views
Skip to first unread message

chro...@googlecode.com

unread,
Mar 12, 2013, 7:33:10 AM3/12/13
to chromi...@chromium.org
Status: Unconfirmed
Owner: ----
Labels: OS-Android Pri-2

New issue 184812 by K.Y.Ser...@gmail.com: Detect backspace keydown event at
the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

Device name: Nexus 4

Application version: Chrome 25.0.1364.169
OS: Anroid 4.2.2; Nexus 4 Build/ JDQ39
Default Android Keyboard

Steps to reproduce:
1. Create text input(with text or without it)
2. Add keydown event listener to this input
3. Place cursor to the beginning
4. Push backspace button

Expected result:
keydown event listener should be called

Actual result:
keydown event listener wasn't called (but it was called when I used build
in Google Korean Keyboard)


--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

chro...@googlecode.com

unread,
Nov 26, 2013, 10:23:59 PM11/26/13
to chromi...@chromium.org

Comment #1 on issue 184812 by cdr...@gmail.com: Detect backspace keydown
event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

I can repeat this bug on the Google Keyboard (English) on Android 4.4.

Other keyboards seem to work fine - all of the following keyboards fire the
correct event with event.keyCode == 8 when BACKSPACE is pressed at the
start of a line:
* Google Korean Keyboard
* Hacker's Keyboard
* a physical keyboard
* iPhone / iPad

I did notice that the ENTER key sends keyCode 13 through correctly when the
GO key is pressed on Google Keyboard, so it seems as though the underlying
issue is fixable.

This issue causes me a few headaches: (i) I cannot use feature detection to
do a work-around but instead I have to do an ugly sniff for "Android" in
the User Agent (ii) in my case I am using backspace to clear a default
value (value shown in placeholder) so my only realistic option is to do an
ugly Android specific fix (fix by not using placeholder, or fix by
implementing my own ugly [x] at end of input).

This bug is probably related to
https://code.google.com/p/chromium/issues/detail?id=118639 and there are a
few other comments in that thread also related to BACKSPACE.

chro...@googlecode.com

unread,
Nov 27, 2013, 2:22:10 AM11/27/13
to chromi...@chromium.org

Comment #2 on issue 184812 by K.Y.Ser...@gmail.com: Detect backspace
keydown event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

Actually after performing some test I begin to think that this issue is
related not to chrome itself but to Google Keyboard. I'm using it in
contentEditable element and it's really mad there. Here is an example:
http://jsfiddle.net/MN3Lb/ . If I click somewhere at the end of the line
(not in the text) my keyboard appears and disappears immediately. It also
can't delete images.

Other keyboards are doing well in this test.

chro...@googlecode.com

unread,
Nov 28, 2013, 12:43:26 AM11/28/13
to chromi...@chromium.org

Comment #3 on issue 184812 by cdr...@gmail.com: Detect backspace keydown
event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

I suspect that to fix this would depend upon issue #118639 being fixed
first (since at present keyCode is sent as 0 for BACKSPACE for the keydown
event).

I did a bunch of testing with different browsers and this issue looks to be
Chrome related.

The following work (KEYBOARD; BROWSER; OS; DEVICE;) :

Samsung Keyboard; Chrome 31.0.1650.59; Android 4.1.2; Galaxy S mini III;
Hackers Keyboard v1.33; Chrome 31.0.1650.59 (537.36); Android 4.3; Galaxy
Nexus:
iOS touch keyboard; Mobile Safari/7534.4.3 (534.46); iOS 5.1.1; iPad 2:
iOS touch keyboard; Mobile Safari/8526.25 (536.26); iOS 6.1.3; iPad 4:
USB Keyboard (OTG cable); Chrome 31.0.1650.59; Android 4.4; Nexus 10:
USB Keyboard (OTG cable); Firefox Browser for Android 25.0; Android 4.4;
Nexus 10:
USB Keyboard (OTG cable); Native Android Browser 4.3-776638 (534.30);
Android 4.3; Galaxy Nexus:
Touch Keyboard and Handwriting Panel; IE11.0 (tested both Desktop and
Modern); Windows 8.1 Pro; Dell S2240T touch screen:

Virtual keyboards on Android Chrome and Native fail (Fail means that
backspace on an empty field fails to send a keydown event):

Google Keyboard 2.0.19123.914326a; Chrome 31.0.1650.59; Android 4.4; Nexus
10:
Samsung Keyboard; Android Native 534.30; Android 4.0.3; Huawei U8666N:
Google Keyboard 2.0.19123.914326a; Chrome 31.0.1650.59; Android 4.1.2;
Galaxy S mini III;
Swype 1.6.3.22544; Native Android Browser 4.3-776638 (534.30); Android 4.3;
Galaxy Nexus:

chro...@googlecode.com

unread,
Nov 28, 2013, 12:48:21 AM11/28/13
to chromi...@chromium.org

Comment #4 on issue 184812 by cdr...@gmail.com: Detect backspace keydown
event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

I created http://jsbin.com/alAKaNaZ/5 to test the keydown events.

chro...@googlecode.com

unread,
Dec 5, 2013, 6:23:49 AM12/5/13
to chromi...@chromium.org

Comment #5 on issue 184812 by K.Y.Ser...@gmail.com: Detect backspace
keydown event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

I've tried your test with FF on nexus 4

user agent = Mozilla/5.0 (Android; Mobile; rv:25.0) Gecko/25.0 Firefox/25.0

Pressing backspace key didn't provide any log

chro...@googlecode.com

unread,
Jan 24, 2014, 12:55:30 AM1/24/14
to chromi...@chromium.org
Updates:
Status: Assigned
Owner: auri...@chromium.org
Labels: Cr-Blink-Editing Cr-Blink-Events Cr-Blink-Input

Comment #8 on issue 184812 by tk...@chromium.org: Detect backspace keydown
event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

(No comment was entered for this change.)

chro...@googlecode.com

unread,
Apr 3, 2014, 4:24:33 PM4/3/14
to chromi...@chromium.org

Comment #9 on issue 184812 by auri...@chromium.org: Detect backspace
keydown event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

Issue 229292 has been merged into this issue.

chro...@googlecode.com

unread,
Apr 3, 2014, 4:45:42 PM4/3/14
to chromi...@chromium.org

Comment #10 on issue 184812 by auri...@chromium.org: Detect backspace
keydown event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

Issue 329376 has been merged into this issue.

chro...@googlecode.com

unread,
Apr 17, 2014, 3:47:36 AM4/17/14
to chromi...@chromium.org
Updates:
Status: Available
Owner: kenji...@chromium.org

Comment #11 on issue 184812 by kenji...@chromium.org: Detect backspace
keydown event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

(No comment was entered for this change.)

chro...@googlecode.com

unread,
Apr 24, 2014, 2:38:11 AM4/24/14
to chromi...@chromium.org
Updates:
Owner: ---
Labels: Needs-Feedback

Comment #13 on issue 184812 by kenji...@chromium.org: Detect backspace
keydown event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

The reason why this is broken is because the Android framework sees no
input and therefore doesn't send the backspace key event (given that there
is nothing to erase).

I believe that issues like these are rooted to inconsistencies between the
model used to represent the actual document:

Document (| represent the caret):
Hello World!
This is a test.
|

Model:
Line1: Hello World
Line2: This is a test.
Input:|


Does anyone know why these editors are handling the document on a line by
line basis?
If they could switch to a model that is closer to the actual document, the
backspace would then fire.

chro...@googlecode.com

unread,
Apr 24, 2014, 4:43:24 AM4/24/14
to chromi...@chromium.org

Comment #15 on issue 184812 by cdr...@gmail.com: Detect backspace keydown
event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

@kenjibaheux

You are suggesting we rewrite our front end code to mitigate or work-around
the issue that only affects our Android users.

Our regret is that this problem:
* only occurs on Android Browsers (which is a very small percentage of our
users),
* there is no possibility for "feature detection" that can be used to
recognise the fault (although we could do ugly browser sniffing).


Also for my situation, your suggested mechanics are not applicable, since
we use the backspace for another usability feature (not multi-line editing).

chro...@googlecode.com

unread,
Apr 30, 2014, 4:53:14 AM4/30/14
to chromi...@chromium.org

Comment #18 on issue 184812 by cdr...@gmail.com: Detect backspace keydown
event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

#17: our use case is clearing a selected value (displayed as a placeholder).

The problem only affects only Android users with a virtual keyboard, which
are only about 0.5% of our user base (desktop browsers and iOS don't have
the bug). Thank you for your suggestions: maybe we could do a workaround,
but the problem isn't a high priority (I will mark this as wontfix in our
issue system since the user can achieve the same outcome, another less
obvious way!)

chro...@googlecode.com

unread,
May 1, 2014, 10:33:45 PM5/1/14
to chromi...@chromium.org

Comment #19 on issue 184812 by calp...@gmail.com: Detect backspace keydown
event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

For a project I am working on I have a similar issue as Stripe. Except I am
not receiving a backspace key event regardless of there being a character
in the input. I have a hidden input field off screen. When certain
character limits are reached, the value is cached and cleared and put into
a formatted div elsewhere. There are multiple of these formatted
div "fields" so as you reach character limits, they begin filling in. I
need the backspace at the beginning of the field in order to determine when
to move "active" state back to the previous formatted div "field". To try
to fix this, I kept a space at the beginning of the field in order to track
when the length is zero, and then activate the previous "field". However,
this is all based on keyup events, which are not fired (nor keydown or
keypress) for backspace at all. At very inconsistent times I can catch an
event, but the keyCode is 0 rather than 8. This only seems to happen when
the backspace follows a letter character. Number characters being
backspaced don't seem to fire the event. I need to be able to trap a
keydown or keyup event in order to tell that something even happened in the
input to check it's length.

chro...@googlecode.com

unread,
May 1, 2014, 10:35:46 PM5/1/14
to chromi...@chromium.org

Comment #20 on issue 184812 by calp...@gmail.com: Detect backspace keydown
event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

For a project I am working on I have a similar issue as Stripe. Except I am
not receiving a backspace key event regardless of there being a character
in the input. I have a hidden input field off screen. When certain
character limits are reached, the value is cached and cleared and put into
a formatted div elsewhere. There are multiple of these formatted
div "fields" so as you reach character limits, they begin filling in. I
need the backspace at the beginning of the field in order to determine when
to move "active" state back to the previous formatted div "field". To try
to fix this, I kept a space at the beginning of the field in order to track
when the length is zero, and then activate the previous "field". However,
this is all based on keyup events, which are not fired (nor keydown or
keypress) for backspace at all. At very inconsistent times I can catch an
event, but the keyCode is 0 rather than 8. This only seems to happen when
the backspace follows a letter character. Number characters being
backspaced don't seem to fire the event. I need to be able to trap a
keydown or keyup event in order to tell that something even happened in the
input to check it's length.

I am running
Chrome 34.0.1847.114
Android 4.4.2; Nexus 5 Build/KOT49H

chro...@googlecode.com

unread,
Jun 18, 2014, 4:58:19 PM6/18/14
to chromi...@chromium.org
Updates:
Owner: guo...@chromium.org

Comment #21 on issue 184812 by guo...@chromium.org: Detect backspace
keydown event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

(No comment was entered for this change.)

chro...@googlecode.com

unread,
Jun 18, 2014, 5:00:21 PM6/18/14
to chromi...@chromium.org
Updates:
Status: Assigned

Comment #22 on issue 184812 by guo...@chromium.org: Detect backspace

chro...@googlecode.com

unread,
Jun 20, 2014, 5:45:59 PM6/20/14
to chromi...@chromium.org
Updates:
Status: Started

Comment #23 on issue 184812 by guo...@chromium.org: Detect backspace
keydown event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

Did some quick investigation. Android does trigger DeleteSurroundText event
with beforeLength=1 and afterLength=0 at the beginning of an inputbox.
Chrome sanitizes the parameters based on the current content of the input
box and since there is nothing to delete before the caret, thus updates the
parameters to beforeLength=0 and afterLength=0. Since the selection is
empty, thus InputMethodController::extendSelectionAndDelete aborts the
action and no keyevent is generated.

One possible solution is to force Chrome to generate keyevent even when
there is nothing to delete. However, the keyevent would have 0 keycode as
addressed in a separate bug 118639.

chro...@googlecode.com

unread,
Jun 23, 2014, 7:44:29 PM6/23/14
to chromi...@chromium.org

Comment #24 on issue 184812 by guo...@chromium.org: Detect backspace
keydown event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

Currently chrome on android generates synthetic key events (UP and DOWN) in
the following cases:

1. when a number key is pressed in non-composition mode.
AdapterInputConnection.sendKeyEvent calls
mImeAdapter.translateAndSendNativeEvents with the real key code.

2. when '\n' or '\t' is pressed. AdapterInputConnection.performEditorAction
calls mImeAdapter.sendKeyEventWithKeyCode with the real key code.

3. when a key is pressed in the composition mode or if it starts the
composition mode. AdapterInputConnection.sendKeyEvent calls
mImeAdapter.checkCompositionQueueAndCallNative, which in turn calls
nativeSendSyntheticKeyEvent or sendKeyEventWithKeyCode with the composition
keycode 229.

No key event is generated when the BACKSPACE key is pressed outside of
composition, in other words, when
AdapterInputConnection.deleteSurroundingText is called. In the reported
bug, since there is no input in the text field, thus IME is not in the
composition mode, thus pressing the BACKSPACE key triggers
deleteSurroundingText and thus no key event is generated.

A cl that generates key events in deleteSurroundingText with a dummy
keycode is under review at https://codereview.chromium.org/348413003/.

chro...@googlecode.com

unread,
Jun 23, 2014, 7:49:28 PM6/23/14
to chromi...@chromium.org

Comment #25 on issue 184812 by guo...@chromium.org: Detect backspace
keydown event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

Currently chrome on android generates synthetic key events (UP and DOWN) in
the following cases:

1. when a number key is pressed in non-composition mode.
AdapterInputConnection.sendKeyEvent calls
mImeAdapter.translateAndSendNativeEvents with the real key code.

2. when '\n' or '\t' is pressed. AdapterInputConnection.performEditorAction
calls mImeAdapter.sendKeyEventWithKeyCode with the real key code.

3. when a key is pressed in the composition mode or if it starts the
composition mode. AdapterInputConnection.setComposingText or
AdapterInputConnection.commitText calls
mImeAdapter.checkCompositionQueueAndCallNative, which in turn calls
nativeSendSyntheticKeyEvent or sendKeyEventWithKeyCode with the composition
keycode 229.

No key event is generated when the BACKSPACE key is pressed outside of
composition, in other words, when
AdapterInputConnection.deleteSurroundingText is called. In the reported
bug, since the text field is empty, thus IME is not in the composition

chro...@googlecode.com

unread,
Jun 23, 2014, 7:51:29 PM6/23/14
to chromi...@chromium.org

Comment #26 on issue 184812 by guo...@chromium.org: Detect backspace
keydown event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

please note the cl above sends a dummy keycode 0, the issue for empty key
code is handled in a separate bug 118639.

chro...@googlecode.com

unread,
Jun 26, 2014, 2:39:49 AM6/26/14
to chromi...@chromium.org

Comment #27 on issue 184812 by bugdro...@chromium.org: Detect backspace
keydown event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812#c27

The following revision refers to this bug:

https://chromium.googlesource.com/chromium/src.git/+/2754bf8d56d3c1b5a123730256214c0953dba9f2

commit 2754bf8d56d3c1b5a123730256214c0953dba9f2
Author: guo...@chromium.org
<guo...@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Thu Jun 26 06:28:14 2014

Generate key event for deleteSurroundingText

Currently Chrome on android does not generate any key event when BACKSPACE
key
is pressed outside of composition, in other words, when
AdapterInputConnection.
deleteSurroundingText is called. It breaks websites who expects to always
receive a KeyDown/KeyUp event when BACKSPACE key is pressed.

This CL fixes the issue by generating key events in deleteSurroundingText.

For more details please refer to the attached bug.


BUG=184812

Review URL: https://codereview.chromium.org/348413003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279928
0039d316-1c4b-4281-b951-d872f2087c98

chro...@googlecode.com

unread,
Jun 26, 2014, 2:44:51 AM6/26/14
to chromi...@chromium.org

Comment #28 on issue 184812 by bugdro...@chromium.org: Detect backspace
keydown event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812#c28

------------------------------------------------------------------
r279928 | guo...@chromium.org | 2014-06-26T06:28:14.528759Z

Changed paths:
M
http://src.chromium.org/viewvc/chrome/trunk/src/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java?r1=279928&r2=279927&pathrev=279928

Generate key event for deleteSurroundingText

Currently Chrome on android does not generate any key event when BACKSPACE
key
is pressed outside of composition, in other words, when
AdapterInputConnection.
deleteSurroundingText is called. It breaks websites who expects to always
receive a KeyDown/KeyUp event when BACKSPACE key is pressed.

This CL fixes the issue by generating key events in deleteSurroundingText.

For more details please refer to the attached bug.


BUG=184812

Review URL: https://codereview.chromium.org/348413003
-----------------------------------------------------------------

chro...@googlecode.com

unread,
Jun 26, 2014, 2:31:21 PM6/26/14
to chromi...@chromium.org
Updates:
Status: Fixed

Comment #29 on issue 184812 by guo...@chromium.org: Detect backspace
keydown event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

(No comment was entered for this change.)

chro...@googlecode.com

unread,
Jul 11, 2014, 11:42:02 AM7/11/14
to chromi...@chromium.org
Updates:
Status: Verified
Cc: b...@chromium.org klo...@chromium.org

Comment #30 on issue 184812 by guo...@chromium.org: Detect backspace
keydown event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

Fix verified on canary.

This was marked as a release blocker for microsoft, anyone could comment
what we need to do next?

chro...@googlecode.com

unread,
Jul 15, 2014, 7:06:16 PM7/15/14
to chromi...@chromium.org
Updates:
Cc: kshw...@chromium.org

Comment #31 on issue 184812 by guo...@chromium.org: Detect backspace
keydown event at the beginning of text input
http://code.google.com/p/chromium/issues/detail?id=184812

ping?

chro...@googlecode.com

unread,
Aug 24, 2014, 10:30:50 PM8/24/14
to chromi...@chromium.org

Comment #33 on issue 184812 by rauz...@gmail.com: Detect backspace keydown
event at the beginning of text input
https://code.google.com/p/chromium/issues/detail?id=184812

see this post oninput of html5 for some cases
http://stackoverflow.com/questions/6056819/input-text-change-events

javascript:
if key pressed empty do backspace actions
else other actions of detectable characters

<input type="text" placeholder="Buscar" id="searchTerm"
oninput="doSearch();" />

tested on android 4.2, chrome 36.0.1085.135

chro...@googlecode.com

unread,
Sep 22, 2014, 4:37:21 AM9/22/14
to chromi...@chromium.org

Comment #34 on issue 184812 by mofaj...@escenic.com: Detect backspace
keydown event at the beginning of text input
https://code.google.com/p/chromium/issues/detail?id=184812

I have got the same issue for Android 4.4.2 .
I am using HTML5 and div for which contenteditable is true.

chro...@googlecode.com

unread,
Apr 2, 2015, 10:07:07 AM4/2/15
to chromi...@chromium.org

Comment #35 on issue 184812 by sebastia...@gmail.com: Detect backspace
keydown event at the beginning of text input
https://code.google.com/p/chromium/issues/detail?id=184812

Issue is still happens.
Samsung Galaxy Tab 4.4.2
Samsung S5 4.4.2
Reply all
Reply to author
Forward
0 new messages