title: on keypress jquery function, backspace doesn't work
body: <p>I implemented a function that add white space like so automatically : </p>
  
  <pre><code>+33 6 XX XX XX XX
  </code></pre>
  
  <p>or </p>
  
  <pre><code>06 XX XX XX XX
  </code></pre>
  
  <p>Here is the script :</p>
  
  <pre><code>$('#num').keypress(function(){
      $this = $(this);
      //remove whitespaces to calculate the length of the string
      $val = $this.val().replace(/\s+/g, '');
      //if it's the case '+33 6 XX XX XX XX
      if ($val.toLowerCase().indexOf("+") &gt;= 0 | $val == "")
      {
       if($val.length == 3){
              $this.val($this.val() + " ");
          }else if($val.length == 4){
              $this.val($this.val() + " ");
          }else if ($val.length &gt;= 5 &amp;&amp; ($val.length)%2 == 0){
              $this.val($this.val() + " ");
          }
      }else{
           if (($val.length)%2 == 0){
              $this.val($this.val() + " ");
          }
      }
  
  });
  </code></pre>
  
  <p>It works perfectly on chrome but on firefox i can't backspace the input.. Any ideas ?</p>
  
  <p>Here is a jsfiddle to illustrate :</p>
  
  <p><a href="https://jsfiddle.net/jd1mwp3p/" rel="nofollow">https://jsfiddle.net/jd1mwp3p/</a></p>