title: Make ENTER act like a button click in Bootstrap
body: <p>I have a basic sign-in page using Bootstrap where a user enters an email address and password and then presses a "Sign-In" button to log into our online app.</p>
  
  <p>The bootstrap button uses the "data-xxx-complete" text identifier to change the color and state of the button to "Authenticating..." after the user has clicked it.</p>
  
  <p>I was able to use an event handler to trap the enter key and force a form submit, but what I really want to do is trap the enter key to make it act just like the user <em>clicking</em> the sign-in button so I get the "Authenticating..." state change on that element before the form submits.  This is important as sometimes the login process takes several seconds.</p>
  
  <p>Here is the button:</p>
  
  <pre><code>echo "&lt;div class='form-group' id='sendBtn1'&gt;";
      echo "&lt;div class='col-xs-3 text-left'&gt;";
          echo "&lt;button type='button' id='sendButton' class='btn btn-primary' autocomplete='off' data-complete-text='Authenticating...' onclick=\"$(this).button('complete');$(this).prop('disabled',true);J_action('signin');\" &gt;";
          echo "Sign In";
          echo "&lt;/button&gt;";
      echo "&lt;/div&gt;";
  echo "&lt;/div&gt;";
  </code></pre>
  
  <p>The <code>J_Action();</code> function called from the sign-in button just calls a simple JS routine that handle where and what to do next with the login.</p>
  
  <p>The code to handle the keypress is in my header as follows:</p>
  
  <pre><code>    ...
      function checkSubmit(e) { 
          if(e &amp;&amp; e.keyCode == 13) {
              J_action('signin');
          }
      }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onKeyPress='return checkSubmit(event)'&gt;
  </code></pre>
  
  <p>Is there a way to directly tell a button in bootstrap to change it's state?  </p>
  
  <p>I tried to add the same JS calls that were in the onClick event on the button itself to the event handler, but am not sure if using the ID name of the button in place of the <code>(this)</code> nomenclature is the right syntax.  This did not work for me to change the state of the button.</p>
  
  <pre><code>    ...
      function checkSubmit(e) { 
          if(e &amp;&amp; e.keyCode == 13) {
              $(sendButton).button('complete');
              $(sendButton).prop('disabled',true);
              J_action('signin');
          }
      }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onKeyPress='return checkSubmit(event)'&gt;
  </code></pre>