How to add keys dynamically to anim or float curves?

Also looking for the answer to this, five years later haha.