# `Mob.Clipboard`
[🔗](https://github.com/genericjam/mob/blob/main/lib/mob/clipboard.ex#L1)

System clipboard access. No permission required.

## Write

    def handle_event("copy", _params, socket) do
      Mob.Clipboard.put(socket, socket.assigns.text)
      {:noreply, socket}
    end

## Read

    def handle_event("paste", _params, socket) do
      case Mob.Clipboard.get(socket) do
        {:clipboard, :ok, text} -> {:noreply, Mob.Socket.assign(socket, :field, text)}
        {:clipboard, :empty}    -> {:noreply, socket}
      end
    end

`get/1` dispatches to the main thread synchronously (same model as
`safe_area/0`) — fast enough to call from any callback.

# `get`

```elixir
@spec get(Mob.Socket.t()) :: {:clipboard, :ok, binary()} | {:clipboard, :empty}
```

Read the current clipboard text synchronously.

Returns `{:clipboard, :ok, text}` or `{:clipboard, :empty}`.

# `put`

```elixir
@spec put(Mob.Socket.t(), binary()) :: Mob.Socket.t()
```

Write `text` to the system clipboard. Fire-and-forget; returns the socket.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
