Jquery Autocomplete Deleting Problem

Jquery Autocomplete Deleting Problem

Hello!
I've a problem with my Jquery Autocomplete script. Basically it show a city list and if does not match any element it shows a popup with toggle function. I have a problem with wrong names.

If I'm typing "ROMERRRR" it shows my error popup correctly. 
I'm using this script that works properly in chrome browser but not from mobile browser.

Infact from Chrome DESKTOP, after the first time, i can use backspace again and again and nothing happen correctly but in my mobile Chrome browser when i press backspace for the first time it close my popup correctly but if i press it again it shows my popup back. An so on... another time it shows and one more it hides the popup.

How can i solve this?

My code: 

  1. <script type="text/javascript">
  2. var comuni = [
  3.  {label:"ROME", link:"http://link1"},
  4. {label:"MILAN", link:"http://link2"},
  5. {label:"PARIS", link:"link3"},
  6. ]; 
  7. var last_key = 0;
    $(function() {
    $("#search_com").autocomplete({
        source: function(request, response) {
            var results = $.ui.autocomplete.filter(comuni, request.term);
            if (!results.length) {
    if(last_key==0){
    $("#no-results_wrap").fadeToggle(300);
    $("#no-results_wrap").click(function(){
    $("#no-results_wrap").css({'display':'none'});
    last_key=1;
    });
    $("#no-results_wrap").focus(function(){
    $("#search_com").css({'display':'none'});
    last_key=1;
    });
    $("#search_com").keyup(function(e){
        if(e.keyCode == 8) {
    $("#no-results_wrap").css({'display':'none'});
    last_key=1;
        }
    });
    }else{
    $("#search_com").keyup(function(e){
        if(e.keyCode == 8) {
    $("#no-results_wrap").css({'display':'none'});
    last_key=1;
        }else{
         last_key=0;
        }
    });
    }
                        } else {
                           $("#no-results").empty();
                      }        
            response(results);
        },
        select: function (event, ui) {
                    $(event.target).val(ui.item.label);
                    window.location = ui.item.link;
                    return false;
                } 
    });
    });
  8. </script>