title: How can I prevent the keyup event fires twice when remove a character from input?
body: <p>When remove a predetermined character from the input keyup event fires twice. How can I prevent this?</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;input type="text" id="search"&gt;
  </code></pre>
  
  <p><strong>JS</strong></p>
  
  <pre><code>var block = {
    'ch1': {
        'key':'/',
        'keycode':'191'
    },
    'ch2': {
        'key':':',
        'keycode':'186'
    },
    'ch3': {
        'key':'=',
        'keycode':'187'
    }
  }
  
  $('#search').on('keyup',function(){
    console.log(checkChar($(this)));
  });
  
  function checkChar($this){
  
    var txt  = $this.val(),
        flag = true;
  
    for(var i=0; i&lt;txt.length; i++) {
  
      $.each(block,function(k,v){
  
        if (txt[i] === v.key) {
          $this.val(txt.slice(0,-1));
          flag = false;
          return false;
        }
  
      });
  
    }
  
    return flag;
  
  }
  </code></pre>
  
  <p><strong>JSBIN</strong></p>
  
  <p><a href="https://jsbin.com/mirocepiqo/1/edit?html,js,output" rel="nofollow">https://jsbin.com/mirocepiqo/1/edit?html,js,output</a> </p>