diff --git a/src/snek/static/chat-input.js b/src/snek/static/chat-input.js index 661bf8b..61648c1 100644 --- a/src/snek/static/chat-input.js +++ b/src/snek/static/chat-input.js @@ -31,11 +31,14 @@ class ChatInputElement extends HTMLElement { this.dispatchEvent(new CustomEvent("change", { detail: e.target.value, bubbles: true })) console.error(e.target.value) }) - this.textBox.addEventListener('keyup', (e) => { - e.preventDefault() - if (e.key == 'Enter' && !e.shiftKey) { - this.dispatchEvent(new CustomEvent("submit", { detail: e.target.value, bubbles: true })) + this.textBox.addEventListener('keydown', (e) => { + + if (e.key == 'Enter') { + if(!e.shiftKey){ + e.preventDefault() + this.dispatchEvent(new CustomEvent("submit", { detail: e.target.value, bubbles: true })) e.target.value = '' + } } })