It's quite simple, include kopiert in your site and start copying text to the clipboard.
Add this to your HTML page:
<script src="https://cdn.jsdelivr.net/npm/kopiert/dist/kopiert.min.js"></script>
<script>
kopiert.toClipboard('This text will be copied to your clipboard') // For example on a button press
</script>
Install kopiert using NPM:
npm install kopiert
Then add the following JavaScript code:
import kopiert from 'kopiert'
kopiert.toClipboard('This text will be copied to your clipboard')
Both methods will copy the specified text to the users clipboard.
<p id="text">This text will be copied to your clipboard.</p>
<button id="btn">Copy text</button>
<script src="https://cdn.jsdelivr.net/npm/kopiert/dist/kopiert.min.js" ></script>
<script>
document.getElementById('btn').addEventListener('click', function() {
const text = document.getElementById('text').textContent
kopiert.toClipboard(text)
})
</script>
- run
yarn lint
ornpm run lint
to run eslint. - run
yarn build
ornpm run build
to produce a minifed version in thedist
folder.
This project was developed by me (@betahuhn) in my free time. If you want to support me:
Copyright 2021 Maximilian Schiller
This project is licensed under the MIT License - see the LICENSE file for details.