/DOM Events


The copy event fires when the user initiates a copy action through browser UI (such as the Ctrl/+C keyboard shortcut or selecting "Copy" from a menu), and in response to an allowed document.execCommand('copy') call.

General info










Element: the focused element (for contentEditable elements - the element containing the start of the selection), or the <body> element.

Default Action

See below.

A handler for this event can modify the provided ClipboardEvent.clipboardData object by calling setData(format, data):

document.addEventListener('copy', function(e){
    e.clipboardData.setData('text/plain', 'Hello, world!');
    e.clipboardData.setData('text/html', '<b>Hello, world!</b>');
    e.preventDefault(); // We want to write our data to the clipboard, not data from any user selection

A handler for this event cannot read the clipboard data using clipboardData.getData().

The event's default action depends on the source of the event and the handler's behavior:

  • A synthetic copy event does not have a default action; otherwise…
  • If the event was not cancelled: copies the selection (if any) to the clipboard;
  • If a handler cancelled the event and called setData(): copies the contents of clipboardData to the clipboard;
  • If a handler cancelled the event without calling setData(): no action.


Property Type Description
target Read only EventTarget The event target (the topmost target in the DOM tree).
type Read only DOMString The type of event.
bubbles Read only Boolean Whether the event normally bubbles or not.
cancelable Read only Boolean Whether the event is cancellable or not.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 58 (Yes) (Yes) No support 45 (Yes)
clipboardData 58 (Yes) 22 (22) No support 45 (Yes)
Feature Android Webview Chrome for Android Edge Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 58 58 (Yes) (Yes) ? 45 ?
clipboardData 58 58 (Yes) 22.0 (22) ? 45 ?

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.