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
+13 -2
View File
@@ -98,6 +98,13 @@ function append(parent, children) {
function clear(el) {
while (el.firstChild) el.removeChild(el.firstChild);
}
function sendOnCtrlEnter(area) {
area.addEventListener("keydown", (ev) => {
if (ev.key !== "Enter" || !(ev.ctrlKey || ev.metaKey) || ev.isComposing || area.disabled) return;
ev.preventDefault();
area.form?.requestSubmit();
});
}
// src/i18n.ts
var de = {
@@ -150,6 +157,7 @@ var de = {
"contact.intro": "Deine Nachricht wird verschl\xFCsselt. Das Netzwerk sieht nur, dass jemand zu dieser Anzeige geschrieben hat, nicht wer und nicht was. Du brauchst kein Konto. Die genaue Adresse gibt der Anbieter selbst frei.",
"contact.rules": "Die erste Nachricht muss kurz sein und darf keine Links enthalten. Das sch\xFCtzt vor Betrug; nach der ersten Antwort des Anbieters entf\xE4llt es.",
"contact.label": "Deine Nachricht",
"compose.hint": "Strg+Enter sendet",
"contact.counter": "{used} / {max} Bytes",
"contact.send": "Verschl\xFCsselt senden",
"contact.sending": "Wird vorbereitet \u2026 (eine kleine Rechenaufgabe gegen Spam)",
@@ -373,6 +381,7 @@ var en = {
"contact.intro": "Your message is encrypted. The network only sees that someone wrote about this listing, not who and not what. You need no account. The owner releases the exact address themselves.",
"contact.rules": "The first message must be short and must not contain links. This protects against scams; it ends once the owner has replied.",
"contact.label": "Your message",
"compose.hint": "Ctrl+Enter sends",
"contact.counter": "{used} / {max} bytes",
"contact.send": "Send encrypted",
"contact.sending": "Preparing \u2026 (a small puzzle against spam)",
@@ -4324,7 +4333,8 @@ function describe(e2) {
return t("send.network");
}
function composer(opts) {
const area = h("textarea", { name: "message", rows: 5, "aria-label": t("contact.label"), required: true });
const area = h("textarea", { name: "message", rows: 5, "aria-label": t("contact.label"), placeholder: t("compose.hint"), required: true });
sendOnCtrlEnter(area);
const counter = h("span", { class: "muted" });
const problem = h("p", { class: "error", role: "alert" });
const button = h("button", { type: "submit", class: "btn primary" }, t(opts.button));
@@ -5116,7 +5126,8 @@ function bubble2(m) {
return h("div", { class: `msg ${mine2 ? "out" : "in"}` }, head, h("p", { class: "pre" }, m.text ?? ""));
}
function composer2(listingId, thread, done, release) {
const area = h("textarea", { rows: 3, "aria-label": t("own.reply"), name: "reply" });
const area = h("textarea", { rows: 3, "aria-label": t("own.reply"), name: "reply", placeholder: t("compose.hint") });
sendOnCtrlEnter(area);
const problem = h("p", { class: "error", role: "alert" });
const send = h("button", { type: "submit", class: "btn primary" }, t("own.send"));
const rel = h("button", { type: "button", class: "btn", onclick: () => release(rel) }, t("own.release"));