I use a text box in a simple chat application. I would like to enable carriage return only when the user presses shift + return and passes the form when the user only clicks on the return key.
I am using the ngKeydown directive. The problem is that when I press enter, the message is sent normally, the text field is cleared, and then the si carriage return is inserted. This means that the event continues to spread ...
Here is the HTML code:
<textarea ng-model="messageTyped" ng-keydown="checkReturn($event)"></textarea>
and here is the corner symbol code:
function chatController($scope, ChatService) { $scope.messages = ChatService.messages $scope.checkReturn = function(event) { if (event.keyCode == 13 && !event.shiftKey) { event.stopPropagation()
I don’t know what I am missing ... Thanks for your help!
angularjs
ybycode
source share