# Force KeyPress

**URL:** <https://forum.kirupa.com/t/force-keypress/186469>\
**Category:** flash\
**Created:** [April 21, 2006, 2:11pm UTC](https://forum.kirupa.com/t/force-keypress/186469 "2006-04-21T14:11:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flashshe](https://avatars.discourse-cdn.com/v4/letter/f/e8c25b/32.png) [@Flashshe](https://forum.kirupa.com/u/Flashshe)\
**Post date:** [April 21, 2006, 2:11pm UTC](https://forum.kirupa.com/t/force-keypress/186469/1 "2006-04-21T14:11:46Z")

</div>

Hey folks! In one of my Flash movies, I need to “force”/fake a Enter or spacebar keypress without the user actually pressing the key. Does anyone know how I could do that?

---

<div class="post-metadata">

**Author:** ![maxticket](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/maxticket/32/245_2.png) [@maxticket](https://forum.kirupa.com/u/maxticket)\
**Post date:** [April 21, 2006, 2:17pm UTC](https://forum.kirupa.com/t/force-keypress/186469/2 "2006-04-21T14:17:59Z")

</div>

Can I ask why? You don’t need Flash to actually pretend the user hit a key.

---

<div class="post-metadata">

**Author:** ![Flashshe](https://avatars.discourse-cdn.com/v4/letter/f/e8c25b/32.png) [@Flashshe](https://forum.kirupa.com/u/Flashshe)\
**Post date:** [April 21, 2006, 2:20pm UTC](https://forum.kirupa.com/t/force-keypress/186469/3 "2006-04-21T14:20:40Z")

</div>

> [@maxticket](#):
>
> Can I ask why? You don’t need Flash to actually pretend the user hit a key.

A possible workaround for the ActiveX updates :)…our users are given the code for hotlinking certain Flash files in blogs and on those blogs JavaScript is not allowed…so I need to “activate” the ActiveX from within Flash since all the workarounds out there use JavaScript in the code.

---

<div class="post-metadata">

**Author:** ![Battleman](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/battleman/32/2141_2.png) [@Battleman](https://forum.kirupa.com/u/Battleman)\
**Post date:** [April 21, 2006, 2:46pm UTC](https://forum.kirupa.com/t/force-keypress/186469/4 "2006-04-21T14:46:34Z")

</div>

Perhaps work around the problem by using an intermediate function - somethingn like:

```auto
if (Key.isDown(Key.Enter)) {
    myFunction();
}

function myFunction():Void {
   // do stuff here
}

```

Then instead of ‘forcing a keypress’ you can just simulate it by calling myFunction()

Hopefully I haven’t missed the point - good luck.

**_Edit_** - sorry - I’ve just realised that I did miss the point! I thought this question was too easy! Sorry, mate. Good luck with the Active X anyway.

---

<div class="post-metadata">

**Author:** ![Flashshe](https://avatars.discourse-cdn.com/v4/letter/f/e8c25b/32.png) [@Flashshe](https://forum.kirupa.com/u/Flashshe)\
**Post date:** [April 21, 2006, 5:43pm UTC](https://forum.kirupa.com/t/force-keypress/186469/5 "2006-04-21T17:43:26Z")

</div>

> [@Battleman](#):
>
> Perhaps work around the problem by using an intermediate function - somethingn like:
> 
> ```auto
> if (Key.isDown(Key.Enter)) {
> myFunction();
> }
> 
> function myFunction():Void {
> // do stuff here
> }
> 
> ```
> 
> Then instead of ‘forcing a keypress’ you can just simulate it by calling myFunction()
> 
> Hopefully I haven’t missed the point - good luck.
> 
> _ **Edit** _ - sorry - I’ve just realised that I did miss the point! I thought this question was too easy! Sorry, mate. Good luck with the Active X anyway.

Thanks so much for your input though. I am really not liking Microsoft right now. I hope someone can help me find a workaround for this ActiveX stuff that doesn’t involve using JavaScipt ☹ Thanks again!
