Error 1119 while trying to check if Enter key is pressed?


txt_input.addEventListener(KeyboardEvent.KEY_UP, eventResponse);

function eventResponse(event:Event):void
{
    if(event.keyCode == Keyboard.ENTER)
    {
        trace("Enter Key Pressed!");
    }
}


stop();

txt_input is a text input field on the stage.

I am running Flash CS3, and am new to actionscript and such, but I have been trying to get that code to work, and in examples, it shows that it works, but, I for some reason get the following error:

1119: Access of possibly undefined property keyCode through a reference with static type flash.events:Event.

I have searched the internet for hours, and the closest thing I have found is that I have to do some sort of casting thing or something, but I’m not sure how to do this.

The only result that came up was in this forum, with the casting thing, so help on how to properly do that is what I need.

So if anyone has an idea as to how to fix this, I’d be much appreciative :slight_smile: