ng-keyup preventDefault() not working

I know it's far from being a best practice, but I really want to understand what's wrong. I wrote the following code in order to distinguish Enter from shift+Enter, and run the "code" I need:

ng-keyup="($event.keyCode == 13 && !$event.shiftKey)
?
  [$event.preventDefault(),
   commentCtrl.edit(comment.id, comment.text),
   comment.edit=false, comment.text]
:
  return"

when I press enter, I still get a \n added to my text... :(

Help please!~

Try the following.

ng-keyup="handleKeyup($event);"

in your controller,

$scope.handleKeyup =  function($event) {
//write your logic here.
}

ended up writing a directive that prevents it...

(function() {
    'use strict';

angular
    .module('PreventEnterDrc', [])
    .directive('preventEnter', function () {
        return {
            restrict: 'A',
            link: function(scope, element) {
                element.bind('keydown keypress keyup', function (event) {
                    if(event.keyCode == 13 && !event.shiftKey){
                        event.preventDefault();
                    }
                });
            }
        };
    })
;
})();