Is it possible to paste from clipboard onclick in Javascript?
Try
el.addEventListener('click', (e) => {
document.execCommand('paste');
});
The clipboard API is included in Chrome 66. Check the jsfiddle here: https://jsfiddle.net/zm490d6a/
Relevant code is:
async function paste(input) {
const text = await navigator.clipboard.readText();
input.value = text;
}
If you are in Chrome 66 or later this will work. However, note that you must give the webpage permission to access the clipboard for security reasons, so the first time you click on the input on that page it will popup asking your permission to access the clipboard. Once you give it access any clicks into the input will paste whatever is on your clipboard.
Here I simply use readText, but you can also use readData for images etc on the clipboard. https://developer.mozilla.org/en-US/docs/Web/API/Clipboard