Its one of those things that people find very hard to accept, not all as you demonstrate. So giving this answer seems to enrage about 65% of the crowd, so you dont get any brownie points for saying it.
I thought that if you want to write a plugin which operates on keys selected in graph editor,
Well to be totally honest, mayas designed as follows: maya has 2 separate API's one for scripting user interactions and one for making nodes/exporters importers and little else. The thing you call the API is reserved for node making so if you operate on the GUI it probably shoudl be a script that calls your c code if needed.
So unless your aim si to make a node stay out of the API.
That is the design fighting it will make you unhappy, using it makes you productive. Tough autodesk kindof broke (or is in fact in process of breaking) this wondefully neat design in maya ~2011 sonow its all just a mess. For now keep to the original desin unteill whatever the new one is going to be clarifies (if it does it can also become big ball of mud). Which is why mayas quality is sliding, dont know if they will emerge victorious, i hope they do.