title: AngularJS: Shift Focus to the Next TextBox using Enter Key
body: <p>I have a form with multiple fields. When I open the form, by default the first field should be set to focus. When I press enter key it has to move to next textbox. I have tried the below code default focus is working but enter key is not working.</p>
  
  <pre><code>app.directive('focus',function($timeout) {
          return {
              restrict: 'A',
              scope : {
                  trigger : '@focus'
              },
              link : function(scope, elem,attrs) {
                  scope.$watch('trigger', function(value) {
                      if (value === "true") {
                          $timeout(function() {
                              elem[0].focus();
                          });                         
                      }                           
                  });
                  elem.bind('keydown', function(e) {
                      var code = e.keyCode || e.which;
                      if (code === 13) {
                        e.preventDefault();
                        elem.next().focus();
                      }
                    });
              }
          };
      });
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>    &lt;input type='text'  class='form-control'  focus='true'/&gt;
      &lt;input type='text'  class='form-control'  focus='true'/&gt;
      &lt;input type='text'  class='form-control'  focus='true'/&gt;
  </code></pre>