I am not sure if I understand your question, let me know if I don't answer it.
You can not attach JS to a keyframe. JS can only be attached to an object or scene. The object does have and "animation end" action which will be called on the last keyframe of an animation (and "animation start" which is called on the first keyframe).