Last active
October 28, 2016 18:28
-
-
Save monove/55bdc98488641f3b7d3771bfe160ee2f to your computer and use it in GitHub Desktop.
Angular Dismiss Keyboard when clicking Enter/Go/-> for Input Field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
angular.module('app') | |
.directive('input', function () { | |
return { | |
restrict: "E", | |
link: function (scope, element, attrs) { | |
element.on("keypress", function (e) { | |
var code = (e.keyCode ? e.keyCode : e.which); | |
if (code == 13 || code == 10) { | |
element.blur(); | |
return false; | |
} | |
}); | |
} | |
}; | |
}); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment