12 Matching Annotations
  1. Mar 2023
  2. Dec 2022
  3. Jul 2022
    1. Pasteboard permission Apps need your permission before accessing the pasteboard to paste content from another app.

      I am going to fucking 🆁🅴🅳🅰🅲🆃🅴🅳 myself.

  4. Mar 2022
    1. In 13.10, Shift+Insert pastes from the selection buffer (the thing that selecting text writes to). In Libre Office, Chrome, and Firefox, Shift+Insert pastes from the clipboard. I would thus like to configure gnome-terminal to do the same.
    1. While this isn't a solution, hopefully this explanation will make it clear WHY. In Ubuntu there are two clipboards at work. One, which everyone is familiar with, the freedesktop.org clipboard (captures Ctrl+C command) The second is a clipboard manager that has been at play since before Ubuntu even existed - X11. The X Server (X11) manages three other clipboards: Primary Selection, Secondary Selection, and Clipboard. When you select text with your pointer it gets copied to a buffer in the XServer, the Primary Selection, and awaits pasting by means of the Mouse 3 button. The other two were designed to be used by other applications in a means to share a common clipboard between applications. In this case the freedesktop.org clipboard manager in Ubuntu already does this for us.
  5. Dec 2021
    1. This example implements text copying when a data-copy attribute is added any HTML element such as a button. You can set this value to either of these:

      1. a hard-coded string — such as data-copy="copy this to the clipboard".
      2. a CSS selector — such as data-copy="#mysection". The text content of the first matching element is then copied.

      Optionally, you can set a custom success message in a data-done attribute:

      <button data-copy="#mysection" data-done="section copied">
        copy text from #mysection

      The button is only shown when navigator.clipboard.writeText() is supported. When clicked, the JavaScript event handler locates the text, copies it to the clipboard, and shows an animated success message.

      The text paste button is very similar except it defines a data-paste attribute which must point to a DOM node:

      <textarea id="pastehere"></textarea>
      <button data-paste="#pastehere">paste</button>
    2. Copy and Paste Data

      The Clipboard API’s readText() and writeText() are convenience options for the more generic read() and write() methods. These have less browser support but are able to copy and paste any type of data such as binary images.

      Copying requires blob data typically returned by a fetch() or canvas.toBlob() method. This is passed to a ClipboardItem constructor so it can be written to the clipboard:

        image = await fetch('myimage.png'),
        blob = await image.blob();
      await navigator.clipboard.write([
        new ClipboardItem({ [blob.type]: blob })

      Pasting is more complex because multiple ClipboardItem objects can be returned with differing content types. It’s therefore necessary to iterate through each type until a useful format is found. For example:

      const clipboardItems = await navigator.clipboard.read();
      for (const clipboardItem of clipboardItems) {
        for (const type of clipboardItem.types) {
          if (type === 'image/png') {
            // return PNG blob
            return await clipboardItem.getType(type);
    3. Cut, Copy, and Paste Events

      The cut, copy, and paste events fire whenever the user initiates a clipboard action in the browser — typically with right-click menus or the keyboard shortcuts mentioned above. This is supported in most browsers and handler functions can intercept the events to make changes using a `clipboardData object* passed as a parameter.

      The following function forces all cut or copied text to be uppercase. Note that e.preventDefault() stops the default cut/copy action which would override it:

      body.addEventListener('cut', cutCopyHandler);
      body.addEventListener('copy', cutCopyHandler);
      // cut or copy event handler
      function cutCopyHandler(e) {
        const selection = document.getSelection();
        // send uppercase text to clipboard
        if (e.type === 'cut') selection.deleteFromDocument();
        // stop default cut/copy

      The following code attaches a paste handler to a specific <textarea> field. The function clears the existing content and prefixes the text "pasted:":

      document.getElementById('field1').addEventListener('paste', pasteEvent);
      // paste event handler
      function pasteEvent(e) {
        // add 'pasted:' to pasted text
        const paste = 'pasted:\n' +
          (e.clipboardData || window.clipboardData).getData('text');
        e.target.value = paste;
        // stop default paste
    4. This works in a similar way to the text demonstration, in that copy and paste buttons must point to DOM elements using a CSS selector in data-copyblob and data-pasteblob attributes. For example:

      <!-- copy image -->
      <img id="myimage" src="myimage.png" alt="any image" />
      <button data-copyblob="#myimage" data-done="image copied">
        copy image
      <!-- paste into DOM -->
      <div id="imagelist"></div>
      <button data-pasteblob="#imagelist">
        paste image

      Try copying image data from a graphics application, then use the paste button.

    1. On OS X, you can access your system clipboard

      How do you achieve this functionality under GNU/Linux operating systems?

  6. Apr 2020
    1. Timed clipboard clearing: KeePass can clear the clipboard automatically some time after you've copied one of your passwords into it.