2

I created a simple AngularJs directive which add a bind to "keypress" event:

app.directive('filterInput', function() {
    return {
        restrict: 'A',        
        scope: {},
        link: function(scope, elem, attr) {

            elem.bind('keypress', function(e) {
                alert(e.code || e.which);
            })

            elem.on('keypress', function(e) {
                alert(e.code || e.which);
            })

        }
    }
})

Just for test there are both "bind" and "on" hooks. This works fine for iOS devices. However In Android, if you press a comma, enter or whatever is not a number the event won't fire.

working JSFiddle, open it on Android device

Update:

I added:

elem.on('input', function(e) {
    alert(e.code || e.which);
})

and now the event is firing for all keys (bytheway the event code is undefined) except for enter (keycode 13). Unfortunately I need to intercept exactly that key.


Ernesto Schiavo
  • 1,020
  • 2
  • 12
  • 33
  • Possible duplicate of [Capture keys typed on android virtual keyboard using javascript](https://stackoverflow.com/questions/30743490/capture-keys-typed-on-android-virtual-keyboard-using-javascript) – reyiyo Oct 10 '17 at 19:02

0 Answers0