How to send messages with ctrl + enter?

jsfiddle.net/gjmt1153

There's chatter. How to make so that the message is not only sent by clicking on a button, and the buttons ctrl + enter. Thanks to caring :)
July 8th 19 at 16:27
2 answers
July 8th 19 at 16:29
$('textarea').on('keydown', function (event) {
 if (event.which === 13 && event.as the ctrlkey property) {
event.preventDefault();

 // the code here send
}
});
didn't work - emmie.Ma commented on July 8th 19 at 16:32
$(document).ready(function() {
$('textarea').on('keydown', function (event) {
if (event.which === 13 && event.as the ctrlkey property) {
event.preventDefault();

$('button').click(function(){
var message = $("textarea").val();
var old = $("#content").html();
$("#content").html(old + " + message + ")
});
}
});
}); - emmie.Ma commented on July 8th 19 at 16:35
:
$(document).ready(function () {
$('button').click(updateContent);

 $('textarea').on('keydown', function (event) {
 if (event.which === 13 && event.as the ctrlkey property) {
event.preventDefault();

updateContent();
}
});
});

function updateContent() {
 var message = $("textarea").val();
 var old = $("#content").html();

 $("#content").html(old + '<p>' + message + '</p>')
}
- Cruz commented on July 8th 19 at 16:38
July 8th 19 at 16:31

Find more questions by tags jQuery