gridland
Hooks

usePaste

Listen for paste events on the canvas

The usePaste hook listens for paste events (Ctrl+V / Cmd+V) on the canvas.

Import
import { usePaste } from "@gridland/web"

Usage

Basic
function Editor() {
  const [text, setText] = useState("")

  usePaste((pasted) => {
    setText((prev) => prev + pasted)
  })

  return <text>{text}</text>
}

Parameters

ParamTypeDescription
callback(text: string) => voidCalled with the pasted text

On this page