# Hack System.setClipboard();

**URL:** <https://forum.kirupa.com/t/hack-system-setclipboard/312715>\
**Category:** flash\
**Created:** [August 11, 2010, 8:26am UTC](https://forum.kirupa.com/t/hack-system-setclipboard/312715 "2010-08-11T08:26:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Esseti](https://avatars.discourse-cdn.com/v4/letter/e/bb73d2/32.png) [@Esseti](https://forum.kirupa.com/u/Esseti)\
**Post date:** [August 11, 2010, 8:26am UTC](https://forum.kirupa.com/t/hack-system-setclipboard/312715/1 "2010-08-11T08:26:53Z")

</div>

Just to be clear, in order for System.setClipboard() to work, it has to be executed within a function that receives either a Keyboard or Mouse Event. Now, in my specific case, I need to hack this so that when I press ‘enter’, I get my string that I want to paste into the clipboard from the internet, and when Flash gets it, THEN it pastes it in.

Here’s an example on how I thought I could do that (unfortunately I didn’t work).

```auto

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyboardHandler);
function keyboardHandler(e:KeyboardEvent):void {
	switch (e.charCode) {
// ENTER key
		case 13:
			getStringFromInternet(e);
			// The lower code will work, but I can't run it because I don't yet have my string, so I have to call this in delayedClipboard();
			//System.setClipboard("It works! But not as I want it to.");
		break;
	};
};
function getStringFromInternet(e):void {
	// do some stuff, then set the clipboard with delayedClipboard()
	delayedClipboard(e);
}
function delayedClipboard(e):void {
	System.setClipboard("It works!");
}

```
