# \[F8\] Keypress simulation inquiry

**URL:** <https://forum.kirupa.com/t/f8-keypress-simulation-inquiry/259148>\
**Category:** flash\
**Created:** [May 1, 2008, 2:23pm UTC](https://forum.kirupa.com/t/f8-keypress-simulation-inquiry/259148 "2008-05-01T14:23:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andir](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@Andir](https://forum.kirupa.com/u/Andir)\
**Post date:** [May 1, 2008, 2:23pm UTC](https://forum.kirupa.com/t/f8-keypress-simulation-inquiry/259148/1 "2008-05-01T14:23:06Z")

</div>

There is a way to “simulate” a key press by calling the broadcastMessage of Key through a “hack” of sorts:

```auto

Key["broadcastMessage"]("onKeyUp");

```

However, I cannot find a way to stuff the code I want to simulate into the Key object. Has anyone run across a “private” variable that I can create a wrapper and populate with the codes I want to simulate?

The reason for this is pretty simple. I want to create a row of fake function keys that the user can press. Instead of linking those for this specific project, I want to be able to re-use the keys in multiple projects and classes that listen to the Key object.

I can pass a code as a parameter by extending the function call above like so:

```auto

Key["broadcastMessage"]("onKeyUp", 112); //f1

```

```auto

Key.addListener(this);
private function onKeyUp(keycode:Number) {
   if (keycode) {
      // use code passed by "fake press"
   } else {
      // use Key.getCode();
   }
}

```

What I’m trying to do is stuff the Key class with a code of my choosing instead of checking the existence of “keycode”
