oncopyEvent
Examples
Execute JavaScript when copying text on an <input> element:
Try it Yourself »
More examples are included at the bottom of this article.
Definition and Usage
The oncopy event triggers when the user copies the content of an element.
Tip:The oncopy event also triggers when the user copies an element, for example, copying an <img> element.
Tip:The oncopy event is typically used for <input> elements with type="text".
Tip:There are three ways to copy elements and content:
- Press CTRL + C
- Select "Copy" from the Edit menu in your browser
- Right-click the mouse button and select the "Copy" command from the context menu.
Browser Support
| Event | |||||
|---|---|---|---|---|---|
| oncopy | Yes | Yes | Yes | Yes | Yes |
Note:The oncopy event may not work in Chrome, Firefox, and Opera browsers when trying to copy an image (see more examples).
Syntax
In HTML:
In JavaScript:
In JavaScript, using the addEventListener() method:
Note:Internet Explorer 8 and earlier IE versions do not supportaddEventListener()method.
Technical Details
| Does it support bubbling: | Yes |
|---|---|
| Can it be canceled: | Yes |
| Event type: | ClipboardEvent |
| Supported HTML tags: | All HTML elements |

More Examples
Examples
Execute JavaScript when copying the text content of a <p> element:
Try it Yourself »
Examples
Execute JavaScript when copying an image:
Try it Yourself »
Related Pages
HTML DOM Reference Manual:onpaste Event
HTML DOM Reference Manual:oncut Event
Event Object Other Extensions