github.com/matm/etcd@v0.3.1-0.20140328024009-5b4a473f1453/mod/dashboard/app/scripts/common/directives/enter.js (about) 1 'use strict'; 2 3 angular.module('etcdControlPanel') 4 .directive('ngEnter', function() { 5 return function(scope, element, attrs) { 6 element.bind('keydown keypress', function(event) { 7 if(event.which === 13) { 8 scope.$apply(function(){ 9 scope.$eval(attrs.ngEnter); 10 }); 11 12 event.preventDefault(); 13 } 14 }); 15 }; 16 });