anilprasad / clipboard-copy

Lightweight copy to clipboard for the web

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

clipboard-copy travis npm downloads

Lightweight copy to clipboard for the web

The goal of this package is to offer simple copy-to-clipboard functionality in modern web browsers using the fewest bytes. To do so, this package only supports modern browsers. No fallback using Adobe Flash, no hacks. Just 30 lines of code.

Unlike other implementations, text copied with clipboard-copy is clean and unstyled. Copied text will not inherit HTML/CSS styling like the page's background color.

Works in the browser with browserify!

install

npm install clipboard-copy

usage

const copy = require('clipboard-copy')

button.addEventListener('click', function () {
  copy('This is some cool text')
})

API

copy(text)

Copy the given text to the user's clipboard.

Note: in most browsers, copying to the clipboard is only allowed if copy() is triggered in direct response to a user gesture like a 'click' or a 'keypress'.

comparison to alternatives

license

MIT. Copyright (c) Feross Aboukhadijeh.

About

Lightweight copy to clipboard for the web

License:MIT License


Languages

Language:JavaScript 100.0%