title: Prevent backspace from deleting in Jquery
body: <p>I have a text box. When a user presses the backspace button, I want to prevent the backspace from deleting text and to give a specific alert e.g. "Do you want to delete"? along with two buttons. Only when the user confirms the delete operation, the subsequent backspace button clicks would delete the texts.</p>
  
  <p>I have written the below code. Though it works fine. but it is not able to prevent the backspace from deleting the text. Can anyone help me out in this?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$("#txtCustNameSHP").keyup(function (e) {
      var key = event.keyCode || event.charCode;
      if (keypresscount == 0 &amp;&amp; key == 8 || key == 46) {
          event.preventDefault();
          $.uxMsg({
              title: "Confirmation",
              msg: "Do you want to delete the Shipper?",
              button1Text: "YES",
              button2Text: "NO",
              button1Click: function () {
                  // CUSTOMER LOV
                  //$("#" + txtCustCodeSHP).text("");                        
                  keypresscount++;
              },
              button2Click: function () {
                  return false;
              },
              width: "350px",
              height: "100px"
          });
      }
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;input id="txtCustNameSHP" value="foobar" /&gt;</code></pre>
  </div>
  </div>
  </p>