# useEventTarget

```ts
import { useEventTarget } from "@pibbl/core";
```

`useEventTarget(handlers, options)` accepts [`PibblEventHandlers`](/reference/types/events/#pibbleventhandlers) and [`PibblEventTargetOptions`](/reference/types/events/#pibbleventtargetoptions), is render-only, and returns the current
focus snapshot while registering/updating a geometric target, its event
handlers, and focus options. Pibbl owns the registration and releases it when the
hook slot is replaced or the component unmounts.

The returned focus state is a [`PibblEventTargetSnapshot`](/reference/types/events/#pibbleventtargetsnapshot).

```tsx
function Target() {
  const path = new Path2D("M0 0h80v40H0z");
  const focus = useEventTarget(
    { onClick: () => undefined },
    { path, fill: true },
  );
  return focus.isFocused ? null : null;
}
```

Use `FocusManagement` for logical focus policy. See the [Custom event targets live example](/playground/#/examples/events-and-interaction/custom-event-targets).

## API details from source

<span id="api-useEventTarget"></span>

Registers a logical event target and returns its current focus and interaction snapshot.

```ts
useEventTarget: (handlers: PibblEventHandlers, options: PibblEventTargetOptions) => PibblEventTargetSnapshot
```

Related API: [useEventTarget](/reference/hooks/use-event-target/), [PibblEventHandlers](/reference/types/events/#pibbleventhandlers), [PibblEventTargetOptions](/reference/types/events/#pibbleventtargetoptions), [PibblEventTargetSnapshot](/reference/types/events/#pibbleventtargetsnapshot).

### Parameters

- **`handlers`** — Handlers for this logical event target. See [PibblEventHandlers](/reference/types/events/#pibbleventhandlers).

- **`options`** — Hit geometry, focus, and target participation options. See
[PibblEventTargetOptions](/reference/types/events/#pibbleventtargetoptions) .

### Returns

The registered target's snapshot. See [PibblEventTargetSnapshot](/reference/types/events/#pibbleventtargetsnapshot).

### See also

[PibblEventHandlers](/reference/types/events/#pibbleventhandlers)

[PibblEventTargetOptions](/reference/types/events/#pibbleventtargetoptions)

[PibblEventTargetSnapshot](/reference/types/events/#pibbleventtargetsnapshot)

[View source — packages/core/src/lib/hooks/use-event-target.ts:32](/source/packages/core/src/lib/hooks/use-event-target-ts/#L32)

## Implementation guidance for agents

Read the [Input, focus, and native HTML companion](/agents/topics/input/) for ownership, adaptation, failure modes, and verification. [Agent start](/agents/) provides the version-selection workflow.

## Complete minimal examples

- [Typed event target](/minimal-examples/events/target/): A geometric Canvas target routes pointer, mouse, touch, wheel, keyboard, input, clipboard, and drag events. [Plain source](/minimal/events/target.tsx)
## Documentation version

Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.
