Cayce K
Cayce K

Reputation: 2338

Detect Paste event in browser for images (jquery/javascript)

I need to be able to detect the paste event. It is centered around images for the most part, but as of now I will accept anything that will detect the event.

I have successfully had 99% of all posted solutions work for Chrome, but that is it. Even the ones that are stating they work for IE, Firefox and more they do not.

If someone can just point me in a direction that they have successfully used to just detect the paste event and have either a console log or alert occur that would be excellent.

I'm not sure if this will make sense, but an on DOCUMENT paste would be ideal as I would not like to specify the paste area.

EDIT: The research that I have done for this has been finding a multitude of options that use .bind() and .on() in conjunction with 'paste'. However, paste event does not seem to fire in IE or Firefox. They work in Chrome, but it is unclear to me on why this is the case.

Upvotes: 3

Views: 3973

Answers (1)

Antoine
Antoine

Reputation: 5691

You can use the Clipboard API.

http://caniuse.com/clipboard

and then use .getAsFile() as described here: https://stackoverflow.com/a/6338207/1052033

Upvotes: 3

Related Questions