Fire a method when click an Enter key

Try this:

<input ng-keyup="$event.keyCode == 13 ? MyFunc() : null" >

At form level you can use this:

<form ng-submit="myFunc()" ...>

I have written below mentioned directive and it works.

Directive :

angular.module('app.directives')
    .directive('ngEnter', function () { //a directive to 'enter key press' in elements with the "ng-enter" attribute

        return function (scope, element, attrs) {

            element.bind("keydown keypress", function (event) {
                if (event.which === 13) {
                    scope.$apply(function () {
                        scope.$eval(attrs.ngEnter);
                    });

                    event.preventDefault();
                }
            });
        };
    })

HTML

<form novalidate name="frm1" autocomplete="off">

   //UI elements      
 <input name="userName" type="text" ng-enter="MyFunc()"/>                         

  <div class="col-sm-3 col-sm-offset-6">
      <button ng-click="MyFunc()">Next Step</button>
   </div>
 </form>

Tags:

Angularjs