ctrl+enter to send message

This commit is contained in:
wangjiacai 2023-04-18 21:38:34 +08:00
parent 6f3df5fc51
commit 489f6b223c

View File

@ -7,11 +7,16 @@
</ul> </ul>
</div> </div>
<div class="fixed-bottom form-inline"> <div class="fixed-bottom form-inline">
<textarea id="msgbox" class="form-control" style="width:85%; float: left; margin-bottom: 20px;" placeholder="说点什么吧"></textarea> <textarea id="msgbox"
class="form-control"
style="width:85%;
float: left;
margin-bottom: 20px"
placeholder="说点什么吧"></textarea>
<button id="btn-send" <button id="btn-send"
class="btn btn-info" class="btn btn-info"
type="button" type="button"
style="width: 10%;" style="width: 10%"
onclick="send_message()" onclick="send_message()"
disabled> disabled>
<svg xmlns="http://www.w3.org/2000/svg" <svg xmlns="http://www.w3.org/2000/svg"
@ -37,8 +42,14 @@
btn_send.disabled = true; btn_send.disabled = true;
} }
}); });
</script>
<script> var textarea = document.getElementById("msgbox")
textarea.addEventListener('keydown', function(e) {
if (e.ctrlKey && e.keyCode == 13) {
send_message()
}
});
function get_history() { function get_history() {
var msgs var msgs
$.ajax({ $.ajax({