Submit using Ctrl + Enter or Click the button

0

I currently use this code to send my messages.

$('#chatEnvia').click(function() {
   $.post( "inc_chatEnvia.php", { acesso: "ok", msg: $("#chatEscrita").val() });
});

I would like to know, how do I when pressed together Ctrl + Enter to run the code to send the messages?

It is important to do submit , both with Ctrl + Enter and with the button press.

    
asked by anonymous 17.08.2017 / 21:41

1 answer

1

I think this is what you need:

$('#chatEnvia').click(function() {
   $.post( "inc_chatEnvia.php", { acesso: "ok", msg: $("#chatEscrita").val() });
});

$('#chatEscrita').keyup(function (e) {
   if (e.ctrlKey && e.keyCode == 13) {
      $('#chatEnvia').trigger('click');
   }
});
    
17.08.2017 / 21:48