node-get-selected-text
TypeScript icon, indicating that this package has built-in type declarations

0.1.8 • Public • Published

node-get-selected-text

CI NPM Version

A tiny Node.js library that allows you to easily obtain selected text across all platforms (macOS, Windows, Linux).

Corresponding Rust package: get-selected-text

Usage

import { getSelectedText } from 'node-get-selected-text'

const selectedText = getSelectedText()
console.log('selected text: ', selectedText)

How does it work?

macOS

Prioritize using the A11y API to obtain selected text. If the application does not comply with the A11y API, simulate pressing cmd+c to borrow from the clipboard to get the selected text.

To avoid annoying Alert sounds when simulating pressing cmd+c, it will automatically mute the Alert sound (Only the Alert sound is muted, it won't affect the volume of listening to music and watching videos). The volume of the Alert sound will be restored after releasing the key.

Therefore, on macOS, you need to grant accessbility permissions in advance. You can use this package: node-mac-permissions

Windows + Linux

Simulate pressing ctrl+c to use the clipboard to obtain the selected text.

Readme

Keywords

none

Package Sidebar

Install

npm i node-get-selected-text

Weekly Downloads

2

Version

0.1.8

License

MIT

Unpacked Size

13.4 kB

Total Files

8

Last publish

Collaborators

  • yetone