Simon
Simon

Reputation: 1125

Detect Backspace Appcelerator Android

I need to detect a backspace in Appcelerator Android. I have an event listener for a searchBox here:

$.searchInputBox.addEventListener('change', function() {
  var searchInput = $.searchInputBox.value; // Get searchInput value.
  if(searchInput.length >= 2){
    // Do some stuff
  }
}

Is there a way for the search box to detect if a user has deleted some text?

Thanks.

Upvotes: 0

Views: 162

Answers (1)

abada henno
abada henno

Reputation: 740

Try this code

$.searchInputBox.addEventListener('keypressed', function(e) {
 if(e.keyCode === [backspace code]) {
                          //I's a backspace
                      }
}

Dont forgot setfocusable ` property to true for search input

Upvotes: 2

Related Questions