angular / angular.js

AngularJS - HTML enhanced for web apps!
https://angularjs.org
MIT License
58.85k stars 27.52k forks source link

ng-keypress does not work on Google Chrome Android browsers #5298

Open evgenyneu opened 10 years ago

evgenyneu commented 10 years ago

Hi, ng-keypress directive does not fire on Google Chrome Android browsers.

Demo: http://plnkr.co/edit/hmCFceDC3CwMbci5SWCe?p=preview

Tested Google Chrome versions 28, 29 and 31 on Android 4.0.3 and 4.3. AngularJS version is 1.2.3

Note: Directive ng-keydown works. Older stock Android browser Chrome v11 works as well.

Thank you

caitp commented 10 years ago

Seems to work on my android 4.1.2's webview

tbosch commented 10 years ago

Hi, as I don't have an Android device with Chrome on Android installed here, could anyone else verify and analyze the reason for this? Maybe @caitp?

Thanks! Tobias

caitp commented 10 years ago

@evgenyneu what device are you seeing this with? Do you see an initial keypress feedback but not subsequent ones? Are you using a different input method like Swype?

I don't have a very good testing environment to really dig into what's happening at this second, but for me I'm seeing the updated value each touch (with native input method) and on the initial touch (with swype)

tbosch commented 10 years ago

@Caitlin: The problem seems the be when using Chrome on Android, not the default WebView...

On Thu, Dec 5, 2013 at 3:33 PM, Caitlin Potter notifications@github.comwrote:

@evgenyneu https://github.com/evgenyneu what device are you seeing this with? Do you see an initial keypress feedback but not subsequent ones? Are you using a different input method like Swype?

— Reply to this email directly or view it on GitHubhttps://github.com/angular/angular.js/issues/5298#issuecomment-29950029 .

caitp commented 10 years ago

I've tested both, as the original issue said it occurred in both --- Both with webkit 534 in the UA string


edit: interestingly with 537 it doesn't work as reported, hmm. I can try to figure out what event it is emitting. It would be interesting to see if using ngTouch solves the issue, as well

The expression doesn't seem to be evaluated for any of the ngEventDirs events, with or without ngTouch :( I don't think I"m going to figure out exactly why not tonight though, I'll look at it tomorrow if nobody else has found it

evgenyneu commented 10 years ago

@caitp I am seeing this issue on Samsung Galaxy Note III and HTC Velocity 4G. There is no initial or subsequent feedback. Nothing at all. I am not using different input methods, using the default.

evgenyneu commented 10 years ago

@caitp ng-keypress does work on stock Android browser on Android 4.0.3 for me. But not in Google Chrome on the same device. On Samsung Android 4.3 it does not work neither on stock nor Chrome.

davgothic commented 10 years ago

I can confirm that this problem is also occurring in the new Chrome 30 based WebView on Android devices running 4.4 (KitKat). Tested using angular version 1.2.0 and 1.2.3.

caitp commented 10 years ago

Yeah as I said, builds using older versions of "webkit" (was chrome still webkit or did it already fork in 534?) it seems to work (for me), but after updating Chrome I am seeing your problem... I'm going to investigate that a bit further today, because it appears that similar issues have popped up on stack overflow and rietveld over the past year

caitp commented 10 years ago

https://gist.github.com/caitp/1f40ff2c3163ecb00d8a I started a gist with links to test cases yesterday...

So the Angular 1.2.4 test (not using ng-model) provides feedback (for me) for focus, blur, keyup, keydown, input, compositionstart, compositionupdate (but never compositionend, interestingly) --- I am not getting keypress, which would account for this bug (I don't think I'm getting it in jQuery either...)

So, there are two problems, 1) is compositionend never appearing, and 2 is the apparent inability to receive keypress

edit

I actually do see compositionend very rarely (but I'm not using a CJK IME, but Swype is very buggy and this probably explains a lot of bugs I see using it :z) --- I never see any composition events without Swype, so whew. But yeah, no keypresses, only keydown/keyup/input

caitp commented 10 years ago

With the most recent addition to those tests, http://plnkr.co/edit/RJykPShOHSr0nUNjXRRW?p=preview,

it appears that even with ng-model, most of these events are being triggered (once again, never getting keypress in Chrome on Android, regardless of jqLite or jQuery, ngModel or not)

So... I don't think emulating the keypress event is a very good idea... but maybe your own app could do that, if it needs to...

Might be worth opening an issue on blink rietveld though maybe

caitp commented 10 years ago

Hey good news, I think I have a solution that might actually work! http://plnkr.co/edit/euPnjrLk918G31aTDPjN?p=preview In testing on my Nexus, with and without Swype, I get pretty good results.

But it would be cool if someone could try this with a CJK IME just so that I can be sure it doesn't break international input.

I'll submit a PR for this, but I'm not totally sure how to write an automated test for this.

perrygovier commented 10 years ago

It appears that in current versions of Chrome for Android, and now with KitKat replacing the native browser, that too, that the onkeypress event does not fire at all. Does this fit everyone else's findings?

casank25 commented 10 years ago

It's being suggested to use 'beforeinput' event instead of keypress. Newer versions of android (I believe starting 4.4.2) are dropping keypress event as this event is getting deprecated. See here: http://www.w3.org/TR/DOM-Level-3-Events/#event-type-keypress. So my guess is that android just chose not to support it anymore.

ibanezje commented 9 years ago

Well 'beforeinput' is not supported or doesn't work in 4.4.2 WebView. Although my usecase is window.onkeydown. It fires allright, but the KeyBoardEvent gives mostly zeros on the charCode property. So am I correct, this issue is here for almost a year? Anyone know of a workaround, this is a showstopper for me on android kitkat.

Narretz commented 8 years ago

@petebacondarwin I don't think this is in the scope of ngTouch.