This solution only works for keystrokes that will trigger the required operation. It works by moving the user cursor to the textarea element before the user completes the corresponding keystroke. It works only for text input. This works for me in firefox and chrome. IE can use the clipboardData object (which is preferable to this hack).
In html somewhere you should create a textarea element with arbitrarily large lines and cols attributes. The clipboard-textarea 'element will be the storage area for pasted and copied data. I hide the element using some style attributes.
script:
var desiredClipboardContents = 'It works'; function onCopyKeyPressed() {
source share