Maxscript- get time frame of a first key and last key


Is there a way that I can get the time frame of the first and last key of the object that animated.
I am trying to add visibility to the object at first key at 0 then first key+ 1 frame to 100 then last key - 1f to 100 and last key as 0.



for example - you can get time for any controller. if no keys - result will be -1. In other cases it will be a positive number.

cnt = $.pos.controller
_k = numKeys cnt
if _k >1 do print #((getKeyTime cnt 1),(getKeyTime cnt _k))