# Function fired twice on sim load

**URL:** <https://forum.kirupa.com/t/function-fired-twice-on-sim-load/255029>\
**Category:** Uncategorized\
**Created:** [March 18, 2008, 12:36pm UTC](https://forum.kirupa.com/t/function-fired-twice-on-sim-load/255029 "2008-03-18T12:36:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [March 18, 2008, 12:36pm UTC](https://forum.kirupa.com/t/function-fired-twice-on-sim-load/255029/1 "2008-03-18T12:36:49Z")

</div>

Hi

I’m using keyDown / mouseWheel to enable a nextImage() in a thumbgallery

it works in testing mode… fine

but when I simulate download, the function gets called twice. I’ve added a simple test to ensure its not being called somewhere else

```auto
 stop();
big = this
listen = new Object();
listen.onKeyDown = function() {
 if (Key.getCode() == Key.LEFT) {
  trace("left");
  if(big == _level0.item0.icon.inner.bigpreview){
  big._parent.prevImage();
 
  }
 } else if (Key.getCode() == Key.RIGHT) {
  if(big == _level0.item0.icon.inner.bigpreview){
  big._parent.nextImage();
  }
 }
};
Key.addListener(listen);
 
 

```
