Using onKeyDown within a class to call a function

Hello, I’m having a bit of trouble with some of the functions in a class I am making. I want to see if a button was pressed, then change some variables, and finally call the update function. My problem is that I cannot call the function updateit() once a key has been pressed. Any help would be greatly appreciated. Here’s the simplified code:

public function updateit():Void{
trace(“updateit worked”);
}

public function navigate():Void {
var myListener = new Object();
myListener.onKeyDown = function() {
if (Key.isDown(Key.RIGHT)) {
//change some variables
trace(“right”);
updateit();
}
if (Key.isDown(Key.LEFT)) {
//change some variables
trace(“left”);
updateit();
}
if (Key.isDown(Key.UP)) {
//change some variables
trace(“up”);
updateit();
}
if (Key.isDown(Key.DOWN)) {
//change some variables
trace(“down”);
updateit();
}
};
Key.addListener(myListener);
}

Thanks for taking a look at it for me.