DeAI Research
Source · w3c

Clipboard API and events

2026

cid 959801a8608f1389fce31b9c3628edebd47e2b118e99e3186b5fcfa52bf143c8 · original · open access · via w3c

Title: Clipboard API and events
Authors: 
Venue: w3c
Year: 2026
Canonical: w3c:clipboard-apis
URL: https://www.w3.org/TR/clipboard-apis/
Collector: w3c
OA: true

ABSTRACT
Clipboard API and events Clipboard API and events W3C Working Draft, 24 June 2026 More details about this document This version: https://www.w3.org/TR/2026/WD-clipboard-apis-20260624/ Latest published version: https://www.w3.org/TR/clipboard-apis/ Editor's Draft: https://w3c.github.io/clipboard-apis/ Previous Versions: https://www.w3.org/TR/2025/WD-clipboard-apis-20251124/ https://www.w3.org/TR/2025/WD-clipboard-apis-20251124/ History: https://www.w3.org/standards/history/clipboard-apis/ Feedback: GitHub Inline In Spec Editors: Rakesh Goulikar (Microsoft) Rohan Raja (Microsoft) Former Editors: Gary Kacmarcik (Google) Anupam Snigdha (Microsoft) Hallvord R. M. Steen (Mozilla) Grisha Lyukshin (Microsoft) Explainer: Async Clipboard API Explainer Copyright © 2026 World Wide Web Consortium. W3C® liability, trademark and permissive document license rules apply. Abstract This document describes APIs for accessing data on the system clipboard. It provides operations for overriding the default clipboard actions (cut, copy and paste), and for directly accessing the clipboard contents. Status of this document This section describes the status of this document at the time of its publication. A list of current W3C publications and the latest revision of this technical report can be found in the W3C standards and drafts index. This document was published by the Web Editing Working Group as a Working Draft using the Recommendation track. Publication as a Working Draft does not imply endorsement by W3C and its Members. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than a work in progress. Changes to this document may be tracked at https://github.com/w3c/clipboard-apis. This document was produced by a group operating under the W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent that the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy. This document is governed by the 18 August 2025 W3C Process Document. 1. Introduction This section is non-normative. This specification defines how the system clipboard is exposed to web applications. There are two general APIs described in this specification: Clipboard Event API - This API provides a way to hook into the common clipboard operations of cutting, copying and pasting so that web application can adjust the clipboard data as required. Async Clipboard API - This API provides direct access to read and write the clipboard data. Since this is considered to be a powerful feature, access to this API is controlled by a permission. 2. Use Cases This section is non-normative. 2.1. Changing Default Clipboard Operations There are many scenarios where it is desireable to change the default clipboard operations (cut/copy/paste). Here are a few examples: Metadata When copying text from a repository of documents, it can be useful for the copied text to include metadata about the source of the copied content. Rich content editing When copying text which contains hyperlinks or other structure, it is often useful to be able to reformat the content to preserve important information. Graphics with built-in semantics In order to make web applications which allow the manipulation of rich text, or of graphic content such as [SVG11], it is useful to provide a mechanism that allows for copying more than just the rendered content. Mathematical information With content such as mathematics, simply copying rendered text and pasting it into another application generally leads to most of the semantics being lost. MathML often needs to be transformed to be copied as plain text, for example to make sure "to the power of" is shown with the caret "^" sign in a formula plain-text input. The XML source could also be placed in the clipboard with the appropriate transformation occurring at paste time. 2.2. Remote Clipboard Synchronization For web applications that communicate with remote devices (e.g., remote access or remote shell applications), there is often a need for the clipboard data to be kept in sync between the two devices. One important aspect of this use case is that it requires access to the clipboard in the absense of a user gesture or interaction. To copy the clipboard data from a remote device to the local clipboard, a web application would take the remote clipboard data and then write() the data to the local clipboard. To copy the local clipboard data to a remote device, a web application would listen for clipboardchange events, read() from the clipboard whenever it is updated, and then send the new clipboard data to the remote device. 2.3. Trigger Clipboard Actions Applications that provide an alternate interface to a user agent sometimes need to be able to trigger clipboard actions in the user agent. As an example, consider a screen reader application that provides a more accessible interface to a standard web browser. While the reader can display content and allow the user to interact with it, actions like clipboard copy need to occur in the underlying browser to ensure that the clipboard content is set correctly (with any metadata added by the browser during copy). 3. Terminology The term editable context means any element that is either an editing host, a textarea element, or an input element with its type attribute set to any of "text", "search", "tel", "url", "email", "password" or "number". 4. Model The platform provides a system clipboard. The system clipboard has a list of system clipboard items that are collectively called the system clipboard data. Each system clipboard item has a list of system clipboard representations. Each system clipboard representation has a name, which is a string, and data, which is a sequence of bytes. The system clipboard has a clipboard change count, which is a value that changes each time the system clipboard data is modified. 5. Clipboard Events 5.1. Clipboard event interfaces The ClipboardEvent interface extends the Event interface. dictionary ClipboardEventInit : EventInit { DataTransfer? clipboardData = null; }; clipboardData A DataTransfer object to hold data and meta data related to the event. [Exposed=Window] interface ClipboardEvent : Event { constructor(DOMString type, optional ClipboardEventInit eventInitDict = {}); readonly attribute DataTransfer? clipboardData; }; clipboardData The clipboardData attribute is an instance of the DataTransfer interface which lets a script read and manipulate values on the system clipboard during user-initiated copy, cut and paste operations. The associated drag data store is a live but filtered view of the system clipboard, exposing mandatory data types the implementation knows the script can safely access. For synthetic events, the drag data store contains the data added by the script that created the event. The clipboardData object’s items and files properties enable processing of multi-part or non-textual data from the clipboard. The interface can be used to construct events. An example is given below: var pasteEvent = new ClipboardEvent('paste'); pasteEvent.clipboardData.items.add('My string', 'text/plain'); document.dispatchEvent(pasteEvent); Note: Synthetic clipboard events will not actually modify the clipboard or the document. In other words, while the script above will fire a paste event, the data will not be pasted into the document. 5.2. Clipboard events 5.2.1. The clipboardchange event The clipboardchange event fires whenever the contents of the system clipboard are changed. These changes could be due to any of the following (non-exhaustive): User-initiated cut or copy actions Scripts that use the § 7 Asynchronous Clipboard API to write to the clipboard Actions that update the clipboard outside the user agent 5.2.1.1. To fire a clipboardchange event To fire a clipboardchange event given a Document document: If document does not have sticky activation and document does not have permission to read from the clipboard, then return. Let global be document’s relevant global object. If document has system focus: Let types be a list of mandatory data types available on the system clipboard. Let changeId be the result of running generate a changeId given document. Let eventInit be a new ClipboardChangeEventInit dictionary with its types member set to types and its changeId member set to changeId. Fire an event named clipboardchange at global, using ClipboardChangeEvent, with eventInit. If document does not have system focus: Set document’s clipboardchange pending flag to true. User agents MAY choose to skip firing clipboardchange events for clipboard changes that have been superseded by more recent changes before the event would be delivered. This optimization can improve performance in scenarios where clipboard changes occur in rapid succession, as delivering obsolete change notifications provides no value to web applications while consuming processing resources. 5.2.1.2. Document focus steps When a Document document gains system focus: If document’s clipboardchange pending flag is true: Set document’s clipboardchange pending flag to false. Let types be a list of mandatory data types available on the system clipboard. Let changeId be the result of running generate a changeId given document. Let eventInit be a new ClipboardChangeEventInit dictionary with its types member set to types and its changeId member set to changeId. Let global be document’s relevant global object. Fire an event named clipboardchange at global, using ClipboardChangeEvent, with eventInit. For documents in nested browsing contexts, the clipboardchange event fires independently in each Document based on its own focus state. A clipboard change will fire an event in the single document that has system focus (if that document has sticky activation or persistent clipboard permissions). Note: The clipboardchange event is only available after sticky activation, unless the document has persistent permission to read from the clipboard. In user agents that support persistent clipboard permissions, sites with such permissions can receive clipboardchange events without sticky activation, as the permission already grants access to more sensitive clipboard data. The changeId provides a unique identifier for each clipboard change operation. For the same clipboard change, all windows and tabs with the same storage key will receive events with identical changeId values, enabling applications with multiple windows to deduplicate events and avoid redundant processing. The identifier is storage key-specific and does not provide cross-storage key correlation capabilities. The clipboardchange event does not bubble and is not cancelable, as it is not triggered by a user action but rather by changes to the system clipboard state. dictionary ClipboardChangeEventInit : EventInit { sequence