---
title: useDesktopClick
description: "Calls a handler when a file is clicked."
---

```tsx
import { useDesktopClick } from 'filedom';

useDesktopClick(path, () => selectPiece());
```

The handler fires when the user clicks the file at `path` without dragging it. Finder's selection does the hit-testing, so no geometry is needed.

## Parameters

```ts
useDesktopClick(
  path: string | undefined,
  onClick?: (() => void)
)
```

`path`: filesystem path to watch. Undefined disables the subscription.

`onClick`: optional handler. Omit it to disable the subscription.

## Returns

Nothing (`void`).
