The Clipboard API provides the ability to respond to clipboard commands (cut, copy, and paste) as well as to asynchronously read from and write to the system clipboard. Access to the contents of the clipboard is gated behind the Permissions API: The clipboard-write permission is granted automatically to pages when they are in the active tab. The clipboard-read permission must be requested, which you can do by trying to read data from the clipboard.
clipboard-write
clipboard-read
This API is designed to supersede accessing the clipboard using document.execCommand().
document.execCommand()
Methods
Clipboard_Read_Text
The Clipboard interface's readText() method returns a Promise which resolves with a copy of the textual contents of the system clipboard.
The "clipboard-read" permission of the Permissions API must be granted before you can read data from the clipboard.
Clipboard_Read_Binary
The read() method of the Clipboard interface requests a copy of the clipboard's contents, delivering the data to the returned Promise when the promise is resolved.
Unlike readText(), the read() method can return arbitrary data, such as images.
Clipboard_Write_Text
The Clipboard interface's writeText() property writes the specified text string to the system clipboard. Text may be read back using either read() or readText().
The "clipboard-write" permission of the Permissions API, is granted automatically to pages when they are in the active tab.
Clipboard_Write_Binary
The Clipboard method write() writes arbitrary data, such as images, to the clipboard. This can be used to implement cut and copy functionality.