# Keyboard event and enter frame timing

**URL:** <https://forum.kirupa.com/t/keyboard-event-and-enter-frame-timing/328865>\
**Category:** Uncategorized\
**Created:** [June 26, 2012, 5:56am UTC](https://forum.kirupa.com/t/keyboard-event-and-enter-frame-timing/328865 "2012-06-26T05:56:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![figs](https://avatars.discourse-cdn.com/v4/letter/f/f05b48/32.png) [@figs](https://forum.kirupa.com/u/figs)\
**Post date:** [June 26, 2012, 5:56am UTC](https://forum.kirupa.com/t/keyboard-event-and-enter-frame-timing/328865/1 "2012-06-26T05:56:46Z")

</div>

Which happens first? And is it consistent?

e.g. if I do something like this (dodgy pseudo code):

```php

addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
addEventListener(Event.ENTER_FRAME, onEnterFrame);

function onKeyDown() { mc.x = 100; }
function onEnterFrame() { mc.x = 200; }
 

```

then (even when madly pressing the keyboard) the mc always appears to have an x position of 200, i.e. the ENTER\_FRAME event is getting called after any KEY\_DOWN events within any given frame.

Is there a consistent rule for this? Can I always rely on the ENTER\_FRAME code getting run after any keyboard event code (within a single frame)?
