# @todesktop/client-selected-text

> Retrieve the selected text from any application.

Latest version **0.27.0** (published 2024-11-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install @todesktop/client-selected-text
pnpm add @todesktop/client-selected-text
yarn add @todesktop/client-selected-text
bun add @todesktop/client-selected-text
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.27.0 |
| Published | 2024-11-27 |
| First published | 2021-11-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | davej, megahertz, isaacaderogba |

## Links

- npm: https://www.npmjs.com/package/@todesktop/client-selected-text
- Repository: https://github.com/ToDesktop/todesktop-selected-text
- Homepage: https://github.com/ToDesktop/todesktop-selected-text#readme
- Issues: https://github.com/ToDesktop/todesktop-selected-text/issues
- npm.io page: https://npm.io/package/@todesktop/client-selected-text

## Recent versions

- 0.27.0 (latest) — 2024-11-27
- 0.26.0 — 2024-11-26
- 0.25.0 — 2024-11-26
- 0.24.0 — 2024-11-26
- 0.23.0 — 2024-11-25
- 0.22.0 — 2024-11-25
- 0.21.0 — 2024-11-25
- 0.20.0 — 2024-11-21
- 0.18.0 — 2024-11-21
- 0.17.0 — 2024-05-02
- 0.16.0 — 2023-10-26
- 0.15.0 — 2023-10-24
- 0.14.0 — 2023-09-13
- 0.13.0 — 2023-05-19
- 0.12.0 — 2022-11-11
- … 10 more at https://npm.io/package/@todesktop/client-selected-text/versions

## README

# ToDesktop Selected Text

Retrieve the selected text from any application.

## Installation

Install `@todesktop/client-selected-text` in your client-side application using

```sh
npm install @todesktop/client-selected-text
```

Installation of the [plugin](https://www.npmjs.com/package/@todesktop/plugin-selected-text) package is also necessary. Using ToDesktop Builder, navigate to **Plugins.** Click on the **Explore** button for "Selected Text" and install the package.

## Usage

Gets selected text by synthesizing the keyboard shortcut "CommandOrControl+c" then reading text from the clipboard

### `getSelectedText`

```js
import { getSelectedText } from "@todesktop/client-selected-text";

getSelectedText().then((selectedText) => console.log(selectedText));
```

### `registerShortcut`

Registers a global shortcut of `accelerator`. The `callback` is called with the selected text when the registered shorcut is pressed by the user

Returns `true` if the shortcut was registered successfully

```js
import { registerShortcut } from "@todesktop/client-selected-text";

const isRegistered = registerShortcut("F6", (selectedText) =>
  console.log(selectedText)
);
```

### `unregisterShortcut`

Unregisters a global shortcut of `accelerator` and is equivalent to electron.globalShortcut.unregister

```js
import { unregisterShortcut } from "@todesktop/client-selected-text";

unregisterShortcut("F6"); // void
```

---
_Source: https://npm.io/package/@todesktop/client-selected-text · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
