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:
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user