c6ae83f121d6f0eea009f57ef78bb8b618d2492ac5367ea98b14aa176283dae25f566591767df38c83ec016a8dbcaf4f517bf0eeec8e2623c01babe10d222d 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # clipboardy [![Build Status](https://travis-ci.org/sindresorhus/clipboardy.svg?branch=master)](https://travis-ci.org/sindresorhus/clipboardy)
  2. > Access the system clipboard (copy/paste)
  3. Cross-platform. Supports: macOS, Windows, Linux, OpenBSD, FreeBSD, Android with [Termux](https://termux.com/), [modern browsers](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API#Browser_compatibility).
  4. ## Install
  5. ```
  6. $ npm install clipboardy
  7. ```
  8. ## Usage
  9. ```js
  10. const clipboardy = require('clipboardy');
  11. clipboardy.writeSync('🦄');
  12. clipboardy.readSync();
  13. //=> '🦄'
  14. ```
  15. ## API
  16. ### clipboardy
  17. #### .write(text)
  18. Write (copy) to the clipboard asynchronously. Returns a `Promise`.
  19. ##### text
  20. Type: `string`
  21. The text to write to the clipboard.
  22. #### .read()
  23. Read (paste) from the clipboard asynchronously. Returns a `Promise`.
  24. #### .writeSync(text)
  25. Write (copy) to the clipboard synchronously.
  26. Doesn't work in browsers.
  27. ##### text
  28. Type: `string`
  29. The text to write to the clipboard.
  30. #### .readSync()
  31. Read (paste) from the clipboard synchronously.
  32. Doesn't work in browsers.
  33. ## FAQ
  34. #### Where can I find the source of the bundled binaries?
  35. The [Linux binary](https://github.com/sindresorhus/clipboardy/blob/master/fallbacks/linux/xsel) is just a bundled version of [`xsel`](https://linux.die.net/man/1/xsel). The source for the [Windows binary](https://github.com/sindresorhus/clipboardy/blob/master/fallbacks/windows/clipboard_x86_64.exe) can be found [here](https://github.com/sindresorhus/win-clipboard).
  36. ## Related
  37. - [clipboard-cli](https://github.com/sindresorhus/clipboard-cli) - CLI for this module
  38. - [copy-text-to-clipboard](https://github.com/sindresorhus/copy-text-to-clipboard) - Copy text to the clipboard in the browser