Hello. I have a text field, not even a textarea, but just an input, there is no button and it should not be (as intended). I need that when you press ENTER in the text field, it performs the ajax function.
<input placeholder='Введите сообщение...' id='txtmess'> function gomess() { //Отправить сообщение var id = $("#idus").text(); var txtmess = $("#txtmess").val(); $.ajax({ type: 'POST', url: '/obr/mess.php', data: 'idus='+ id +'&txt='+ txtmess, success: function(data) { alert(data); }, error: function(xhr, str){ alert(data); } }); } I found such a function onkeydown , but I don’t know how to use it ... Tell me some functions or preferably a script for an example.