title: Angularjs - next input on keypress
body: <p>I've been trying to implement a directive that watch everytime the user hit the keyboard.</p>
  
  <p>I have four different inputs and each of them receives a single character and the user should fill the next form </p>
  
  <p>I wrote a directive for this but it doesn't work </p>
  
  <p>here's my code: </p>
  
  <p>JS: </p>
  
  <pre><code>var app = angular.module('app', []);
  app.directive('focus', function() {
    return {
      restrict: 'A',
      link: function($scope,elem,attrs) {
  
        elem.bind('keydown', function(e) {
           elem.next().focus();
  
        });
      }
    }
  })
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div ng-app="app"&gt;
      &lt;form&gt;
          &lt;input  focus type="text"   /&gt; 
          &lt;input  focus type="text"   /&gt; 
          &lt;input focus type="text"   /&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Jsfiddle : <a href="http://jsfiddle.net/Y2XLA/109/" rel="nofollow noreferrer">http://jsfiddle.net/Y2XLA/109/</a></p>
  
  <p>very similar question: <a href="https://stackoverflow.com/questions/18086865/angularjs-move-focus-to-next-control-on-enter">angularjs move focus to next control on enter</a> </p>
  
  <p>Probably it's something simple but I'm not getting it right </p>
  
  <p>Thanks a lot!</p>