shift+enter doesnt submit chat message

This commit is contained in:
iou1name 2018-06-17 18:09:11 -04:00
parent d4b6c14e23
commit 35c052350d

View File

@ -29,9 +29,10 @@
}); });
mtarea = document.getElementById('messageTextarea'); mtarea = document.getElementById('messageTextarea');
mtarea.addEventListener('keypress', function(event) { mtarea.addEventListener('keypress', function(event) {
if (event.key == 'Enter') { if (event.key == 'Enter' && !event.shiftKey) {
text = mtarea.value; text = mtarea.value.trim();
mtarea.value = ''; mtarea.value = '';
if (text == '') { return; }
socket.emit('message', {message: text, name: 'Anonymous', room: '{{ room_id }}'}); socket.emit('message', {message: text, name: 'Anonymous', room: '{{ room_id }}'});
} }
}); });