# EventListener class

**URL:** <https://forum.kirupa.com/t/eventlistener-class/280838>\
**Category:** flash\
**Created:** [February 2, 2009, 12:56am UTC](https://forum.kirupa.com/t/eventlistener-class/280838 "2009-02-02T00:56:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phed](https://avatars.discourse-cdn.com/v4/letter/p/6de8d8/32.png) [@phed](https://forum.kirupa.com/u/phed)\
**Post date:** [February 2, 2009, 12:56am UTC](https://forum.kirupa.com/t/eventlistener-class/280838/1 "2009-02-02T00:56:17Z")

</div>

Hi,

I am having trouble getting a simple event listener class to work. The class is:

```auto
package {

    import flash.display.Sprite;
    import flash.events.*;
    
    public class KeyEvent extends Sprite {
        private var eventSprite:Sprite;
        public function KeyEvent() {
            setUp();
        }
        private function setUp(){
        trace("In setUp");
            eventSprite = new Sprite();
            addChild(eventSprite);
            eventSprite.addEventListener(KeyboardEvent.KEY_DOWN, keyList);
        }
        private function keyList(){
            trace("In keyList");
        }
    }
}

```

and I am adding it to the first frame of my flash file like this:

```auto
import KeyEvent;
var test:KeyEvent = new KeyEvent();

```

and I have the ClassPath pointing to the folder that contains this .as file.

I do get the trace “In setUp” but I’m not getting seeing any Keyboard events. There also aren’t any errors showing up in output so I am kind of stumped.

Thanks for any help!

Phed
