diff --git a/chat-init.js b/chat-init.js index 99f24fa..8ff6b11 100644 --- a/chat-init.js +++ b/chat-init.js @@ -572,11 +572,13 @@ document.addEventListener("DOMContentLoaded", () => { }); sendButton.addEventListener("click", handleSendMessage); - // Send on Enter (newline with Shift+Enter) + // Send on Enter, allow newline with Shift+Enter chatInput.addEventListener('keydown', (e) => { - if (e.key === 'Enter' && !e.shiftKey) { + if (e.key === 'Enter') { + if (e.shiftKey) return; // allow newline e.preventDefault(); - handleSendMessage(); + // Trigger the same action as the send button + sendButton.click(); } }); sendButton.disabled = chatInput.value.trim() === ""; diff --git a/simple.js b/simple.js index 7b968fd..80c5b8d 100644 --- a/simple.js +++ b/simple.js @@ -269,21 +269,30 @@ document.addEventListener("DOMContentLoaded", () => { simpleSendBtn.addEventListener("click", () => { const message = simpleInput.value.trim(); if (message === "") return; - const currentSession = Storage.getCurrentSession(); - currentSession.messages.push({ role: "user", content: message }); - Storage.updateSessionMessages(currentSession.id, currentSession.messages); - appendSimpleMessage("user", message, currentSession.messages.length - 1); - simpleInput.value = ""; - simpleSendBtn.disabled = true; - window.sendToPollinations(() => { - const updatedSession = Storage.getCurrentSession(); - const lastMessage = updatedSession.messages[updatedSession.messages.length - 1]; - if (lastMessage.role === "ai") { - appendSimpleMessage("ai", lastMessage.content, updatedSession.messages.length - 1); - } - simpleInput.focus(); - }); - }); + const currentSession = Storage.getCurrentSession(); + currentSession.messages.push({ role: "user", content: message }); + Storage.updateSessionMessages(currentSession.id, currentSession.messages); + appendSimpleMessage("user", message, currentSession.messages.length - 1); + simpleInput.value = ""; + simpleSendBtn.disabled = true; + window.sendToPollinations(() => { + const updatedSession = Storage.getCurrentSession(); + const lastMessage = updatedSession.messages[updatedSession.messages.length - 1]; + if (lastMessage.role === "ai") { + appendSimpleMessage("ai", lastMessage.content, updatedSession.messages.length - 1); + } + simpleInput.focus(); + }); + }); + + // Send on Enter, allow newline with Shift+Enter + simpleInput.addEventListener('keydown', (e) => { + if (e.key === 'Enter') { + if (e.shiftKey) return; // allow newline + e.preventDefault(); + simpleSendBtn.click(); + } + }); function appendSimpleMessage(role, content, index) { const container = document.createElement("div");