javascript – How to access clipboard image through browser?

Question:

Does anyone have any idea how to access the image that is on the clipboard when we print a screen on some screen? What I need is to access the image by ctrl + v in the browser, exactly how this application works: http://pasteboard.co/

the code I got for the event is this one, and it works, however how to access the image from this point?

$(document).bind('paste', function (evt) {
   alert('ctrl + V funciona');
});

Detail: browser : Google Chrome

Answer:

I found this plugin http://www.codersgrid.com/2014/02/26/paste-js-retrieve-the-data-from-clipboard-in-javascript/

it worked perfectly for my purpose, for copying text and images.

just include the .js file and use the code below.

paste = $.paste().appendTo('body');
paste.on('pasteImage', function (ev, data){
console.log("dataURL: " + data.dataURL)
});
paste.on('pasteText', function (ev, data){
console.log("text: " + data.text)
});
paste.focus(); // it's actually a hidden div element

// ... when you don't need it anymore
paste.remove();

examples and more information at the link.

Scroll to Top