There is no one function for anything. There are many different methods to make something happen, especially something as broad as collision detection.
In addition, using KeyUp and KeyDown along with a KeyCode detector will give you problems.
Use an event handler with an enterFrame function instead.