/clipboard-api

W3C Clipboard API usage example

Primary LanguageHTML

Clipboard API

Sample for Clipboard API and events in web applications (without asynchronous Clipboard API), you can try to paste image file from system's clipboard, either files or screenshot.

Codepen: https://codepen.io/tvpsh2020/pen/KZvpBE

Demo: https://morning-eyrie-32138.herokuapp.com/

When trying to paste image, it works on macOS with Chrome, but Windows with Chrome can only paste the screenshot in clipboard. Pasting text is fine on both macOS and Windows.

Reference

[1] Clipboard API and events (W3C latest published version) - https://www.w3.org/TR/clipboard-apis

[2] Unblocking Clipboard Access (Google) - https://developers.google.com/web/updates/2018/03/clipboardapi

[3] DataTransfer (MDN) - https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent

[4] ClipboardEvent (MDN) - https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer