> For the complete documentation index, see [llms.txt](https://analog.groupthought.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://analog.groupthought.com/reference/alpine/submittable-textarea.md).

# x-submittable-textarea

A directive that adds Cmd+Enter or Ctrl+Enter as a textarea submit shortcut.

A directive that adds a keyboard submit shortcut to a textarea.

| Directive                | What it does                                                            |
| ------------------------ | ----------------------------------------------------------------------- |
| `x-submittable-textarea` | Cmd+Enter on Mac, or Ctrl+Enter elsewhere, submits the closest `<form>` |

The shortcut calls `requestSubmit()`, so browser validation and submit handlers run the same as a click on the submit button. A textarea swallows plain Enter for new lines, so the modifier key is what makes submitting from the keyboard possible.

## Examples

### A submit shortcut on a comment form

Use `x-submittable-textarea` on the textarea of any form:

```html
<form method="post">
  <textarea name="comment[body]" rows="8" required x-submittable-textarea></textarea>
  <button type="submit">Post comment</button>
</form>
```

Analog uses this on the article comment form and on the gift card recipient message, so a shopper who finishes typing can submit without reaching for the mouse.

## Options

`x-submittable-textarea` takes no expression and no modifiers.
