# Copy to clipboard using Javascript macro

I'm pretty inexperienced with Javascript, especially within LaTeX, so I'd like some pointers, guidance or even an MWE of my proposed "button":

I want to create a button to copy data to the system clipboard. For this I'd like to suggest using a workaround with a flash leak (don't know if it works):

function copy(str) {
var D=document;
if(!copy.div) { copy.div = D.createElement('div'); D.body.appendChild(copy.div);  }

flashVar = "Q1dTB3kAAAB4nKtgYI1nYOBfwMDAw8jgzPT//3975lAGBoYOdQYWhu\
SczIKk/MSiFIac1Lz0kgyG4MriktRchuLUEme41DQmBg4GGRDJ6Cc0l4l  BAibCzsDO\

copy.div.innerHTML =  '<embed src="'+flashVar+'" FlashVars="clipboard='+encodeURIComponent(str) +
'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
}


I want to use the following button which will do the copying:

\documentclass[11pt,a4paper]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\newcommand*\button{%
\tikz[baseline=(key.base)]
\node[%
draw,
fill=white,
rectangle,
rounded corners=2pt,
inner sep=1pt,
line width=0.5pt,
font=\scriptsize\sffamily
](key) {Ctrl\strut}
;
\tikz[baseline=(key.base)]
\node[%
draw,
fill=white,
rectangle,
rounded corners=2pt,
inner sep=1pt,
line width=0.5pt,
font=\scriptsize\sffamily
](key) {C\strut}
;
}

\begin{document}
\button
\end{document}


• I meant to use this question as a more specific workaround solution, while the other would be LaTeX exclusive. This would allow people with the same question / functionality in mind to differentiate and choose the answer that suits their needs best. I've certainly considered all these issues with externalization of macros of this kind, but I simply see no feasible solution to this issue using LaTeX exclusively. LaTeX offers a package that does allow for copy pasting of say, listing environments, but that's not exactly what I'm looking for. @Rüdiger Voigt – 1010011010 May 1 '14 at 14:57