v144 · miscellaneous

Clipboardchange event

The "clipboardchange" event fires whenever the system clipboard contents are changed either by a web app or any other system application. This allows web-apps like remote desktop clients to keep their clipboards synchronized with the system clipboard. It provides an efficient alternative to polling the clipboard(using Javascript) for changes.

concepts

  1. Clipboard Watcher

    An event that fires when the system clipboard changes — from any source, not just the current page. Pair with the existing read APIs to react to copy events from other apps.

  2. State Mirror

    The motivating use case: a paste toolbar button that enables / disables in lockstep with the clipboard's available formats, like a native app.

  3. Format Inspector

    Subscribe once, then copy anything — text, screenshots, rich HTML from another tab. The inspector lists every MIME type the clipboard is offering and previews the richest one.

  4. Clipboard Router

    Toggle-based MIME-type router: plain text goes to a text preview, HTML to a sanitized render, images to a canvas thumbnail. Enable/disable each route and watch the activity log dispatch each clipboardchange event to the right handler in real time.

why it shipped

Today, a web-app can monitor the system clipboard by polling and reading the clipboard through async clipboard API at regular intervals. For example, web based remote desktop clients like Chrome Remote desktop may read the clipboard contents for changes on every page focus event which is inefficient. Some Github links also suggests polling of clipboard being performed in Electron JS apps like (https://gist.github.com/LewdEwe-ErikWallace/d6e36f899a77a4f05e46388c254d014f).

references