Keyframes and MaxKey values issues!

Sorry for this newbie question but I can't find a solution.
I'll try to make a script that use MAXKeys methods, I use methods like deletekey, selectkey, moveKey but return me the same error "RuntimeError: Key index out of range in getkey" or selectKey or whatever methods. So what I'm doing wrong? I still don't understand because command like deleteKeyS or selectKeyS are ok!

this driving me crazy.. someone has any help? thanks