Skip to content

Instantly share code, notes, and snippets.

@monove
Last active October 28, 2016 18:28
Show Gist options
  • Save monove/55bdc98488641f3b7d3771bfe160ee2f to your computer and use it in GitHub Desktop.
Save monove/55bdc98488641f3b7d3771bfe160ee2f to your computer and use it in GitHub Desktop.
Angular Dismiss Keyboard when clicking Enter/Go/-> for Input Field
(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