demo · v140
Remote Desktop Sync
The motivating use case from the chromestatus entry: a remote desktop client mirroring the local clipboard to a remote VM. Compare event-driven sync to the polling-on-focus approach Chrome Remote Desktop used to ship with — same correctness, dramatically less work.
Behind a flag in pre-140
The clipboardchange event ships unflagged in Chrome 140+. In earlier builds, enable chrome://flags/#clipboard-change-event. This page falls back to polling when the event is absent.
Sync strategy:
Local (this tab)
— nothing copied yet —
Remote VM (simulated)
— not synced —
Clipboard reads
0
Wasted reads (no change)
0
Syncs delivered
0
Idle — start a session and copy something.
The chromestatus motivation calls out remote desktop clients by name: today they read the clipboard on every focus event, even when nothing changed. With the event, the read only happens when there is something new to sync.
// event-driven (Chrome 140+)
navigator.clipboard.addEventListener("clipboardchange", async () => {
const text = await navigator.clipboard.readText();
await sendToRemote(text); // only fires when there is a real change
});
// legacy CRD-style polling
window.addEventListener("focus", async () => {
const text = await navigator.clipboard.readText();
if (text !== lastSeen) { lastSeen = text; await sendToRemote(text); }
});
see also
- Clipboardchange event — feature index
- Clipboard Watcher — generic event log
- ChromeStatus entry
- Spec PR