Mc functions inside functions

I created an empty movie clip. The object in the clip is drawn with actionscript.

I wanted for the object to do different things when different keys were pressed. Like so:

clip.onKeyDown = function() {
if (Key.getCode() == Key.DOWN) {
clip.onEnterFrame = function() {
_root.callFunction();
}
} else if (Key.getCode() == Key.UP) {
clip.onEnterFrame = function() {
_root.callFunction();
}
}
}

It’s a simple example showing that the onEnterFrame function does about the same thing for each keys. Am i doing this right, or can the onEnterFrame function be defined once and i can call it from the onKeyDown function?

Thanks,
Jerome