From 88085c2a14cd571c9c72214346968ea8d588ffa3 Mon Sep 17 00:00:00 2001 From: G-Fourteen Date: Thu, 11 Sep 2025 14:55:36 -0600 Subject: [PATCH] Allow Enter key to send messages --- chat-init.js | 15 ++++----------- simple.js | 6 ++---- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/chat-init.js b/chat-init.js index 7a1d947..6974640 100644 --- a/chat-init.js +++ b/chat-init.js @@ -574,18 +574,11 @@ document.addEventListener("DOMContentLoaded", () => { // Send on Enter; newline with Shift+Enter chatInput.addEventListener('keydown', (e) => { - // IME safety and repeats - if (e.isComposing || e.key !== 'Enter') return; - - if (e.shiftKey) { - // allow newline - return; + if (e.key === 'Enter' && !e.shiftKey) { + e.preventDefault(); + handleSendMessage(); } - - e.preventDefault(); - // Do not rely on button state—call the handler directly. - handleSendMessage(); - }, { once: false }); + }); sendButton.disabled = chatInput.value.trim() === ""; chatInput.dispatchEvent(new Event("input")); const initialSession = Storage.getCurrentSession(); diff --git a/simple.js b/simple.js index 525a0b7..4562340 100644 --- a/simple.js +++ b/simple.js @@ -286,12 +286,10 @@ document.addEventListener("DOMContentLoaded", () => { }; simpleSendBtn.addEventListener("click", handleSimpleSend); - // Send on Enter, allow newline with Shift+Enter + // Send on Enter; newline with Shift+Enter simpleInput.addEventListener('keydown', (e) => { - if (e.key === 'Enter') { - if (e.shiftKey) return; // allow newline + if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); - // Call the same handler used by the send button handleSimpleSend(); } });