Send messages with Ctrl+Enter

Ctrl+Enter (Cmd+Enter on a Mac) submits the buyer's and the owner's message
boxes through the normal form, so the usual checks apply. Plain Enter still
adds a line. The empty box hints at the shortcut. Not added to the publish
description or the address-release note, where it could submit by accident.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 20:55:30 +01:00
co-authored by Claude Sonnet 5.5
parent 19fea7f524
commit 71e6dc8658
7 changed files with 80 additions and 6 deletions
+9
View File
@@ -34,3 +34,12 @@ export function append(parent: Node, children: Child[]): void {
export function clear(el: Element): void {
while (el.firstChild) el.removeChild(el.firstChild);
}
/** Lets Ctrl+Enter (Cmd+Enter on a Mac) send the form a text box belongs to, like its Send button. */
export function sendOnCtrlEnter(area: HTMLTextAreaElement): void {
area.addEventListener("keydown", (ev) => {
if (ev.key !== "Enter" || !(ev.ctrlKey || ev.metaKey) || ev.isComposing || area.disabled) return;
ev.preventDefault();
area.form?.requestSubmit();
});
}