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

keyboard events do not behave as expected on mobile #6176

Closed
VictorienTardif opened this issue Mar 3, 2016 · 8 comments
Closed

keyboard events do not behave as expected on mobile #6176

VictorienTardif opened this issue Mar 3, 2016 · 8 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@VictorienTardif
Copy link

  • onKeyPress is never triggered
  • onKeyDown event.key is always Unidentified, event.keyCode is always 229, event.charCode is always 0, event.which is always 229.

(tested on Google Nexus 5, Android 6.0.1, Google Chrome 48.0.2564.95)

@jimfb
Copy link
Contributor

jimfb commented Mar 4, 2016

Can you provide a jsfiddle that demonstrates the issue. Also, some of these things surprise me (event.keyCode is always 229, event.charCode is always 0, event.which is always 229), can you verify that the native event is correct (eg. native addEventListener) on your device.

@VictorienTardif
Copy link
Author

@jimfb here is a jsfiddle with both syntheticEvent and native event : https://jsfiddle.net/rzpwd77y/38/

Well, well, well... I had not tried the native event yet and it appears that it's not triggered at all on mobile. (on mine at least.) But the React SyntheticEvent is triggered once, with the values Unidentified and 229.
By the way, charCode is always 0?

Anyway, It seems that this is not really a bug on React side since the native event is not event triggered. Although the behavior of the syntheticEvent is weird then.

I have to understand why I have a mobile not triggering keyboard events and how to handle it... I should not be the only one..

@jimfb
Copy link
Contributor

jimfb commented Mar 6, 2016

I agree, the behavior of the synthetic event sounds weird, given that the other events are not firing. This is probably a weird side effect of some event api smoothing that we're doing (and apparently we have a bug there that is causing nonsensical events to be fired). I tried your fiddle on my android (different model/version) and did not get any of the mysterious synthetic events (at least as far as I can tell, I got no events on the android). I don't have a phone matching the specs you mentioned, so it's a bit difficult for me to debug further on my end. If you're able to debug on your end and submit a PR, that would be much appreciated!

@jquense
Copy link
Contributor

jquense commented Mar 6, 2016

I have the same phone and specs as @VictorienTardif (Nexus 5, 6.0.1, chrome 48.0.2564.95) and got the same results as @jimfb: no native or synthetic events fired when typing

@jimfb jimfb added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Mar 6, 2016
@VictorienTardif
Copy link
Author

@jimfb @jquense I don't know why but now I see no event either. Not even the synthetic event with 229 and 0 that I used to see. So, the behavior seems to be "normal" : no native event = no synthetic event. The remaining question is why don't we have an event?

I did a pure html / javascript fiddle to see if I can handle events : https://jsfiddle.net/fdm3r1vv/6/

The thing is, the keyDown event is triggered but the keyPress event is not. Anyway, I have an event!

@syranide
Copy link
Contributor

syranide commented Mar 7, 2016

@jimfb
Copy link
Contributor

jimfb commented Mar 7, 2016

This is starting to sound increasingly like a browser quirk rather a bug in the React core. I suppose one question remaining is: Is this an API quirk that we want to smooth out?

@jimfb
Copy link
Contributor

jimfb commented Jun 8, 2016

This is unactionable in its current state. As of March, it looks like a browser quirk, and it is not clear that we want to smooth it. If we decide that we want to smooth it out, we can reopen. In the meantime, closing as unactionable, since it doesn't appear to be a bug in React.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

4 participants