Ng-keyup on Android doesn't fire on Space char(32)


#1

I have an app that watches the KeyUp event using ng-keyup(myFunction($event)) to detect a space. When the Space is pressed I execute some logic. This logic worked in my app in production on all form factors: (iOS & Android, plus testing in Ripple).

All of a sudden in my latest version it recognized all keypreses except for space. The only thing that changed in this part of the code was:

  • Upgraded to Ionic 1.2.3 from 1.1.0

I am using Angular Version 1.4.3 in both cases (Working and Non Working) (Best I can tell, I thought I upgraded Angular, but my Source Control says I didn’t)

On iOS and Ripple it still detects the space. But on the android itself, it doesn’t fire the keypress event at all. Or it does fire but leaves the $event.keyCode = the last letter pressed. I can’t get a debugger on an android device, so I don’t know.

Here are some Code to go with it:
<ion-item class="item-button-right"> <input type="text" class="item-input" style="width:100%" placeholder="Type an Identifer Here..." name="Flight.RouteOfFlight" ng-model="state.AirportEntry" ng-keyup="airportChange($event)" zng-blur="airportChange(state.AirportEntry)"> <button class="button button-positive" ng-click="searchAirport()" type="button"> <i class="icon ion-chevron-right"></i> </button> </ion-item>

$scope.airportChange = function ($event) {

// $scope.lastKey = $event.keyCode;
if ($event.keyCode == 32) {
$scope.searchAirport();
} else {
curAirport += String.fromCharCode($event.keyCode);
}
};


#2

I am also facing the same issue, can anyone please let us know, where we are going wrong.


#3

Try to $watch your variable

JS

$scope.$watch('search.input',function(){
   $scope.doSearch('watched!'); //call your function here
});

HTML

<input type="text" placeholder="ابحث" ng-model="search.input">