Lately, I've been doing a lot of animation with binary values: things such as changing the visibility of an object, changing the value of a constraint from 0 to 1, etc. The way I'm doing this currently is by, on one frame, keyframing it, then on the next frame, changing the value and adding a new keyframe. But, since there aren't actually any frames in between the keyframes, this seems like a weird way to do it. Is there any better way? Or is this how it's done? Are there any add-ons that make this more elegant?
When keyframing binary values there is no need to include a "holding" keyframe as you have described before each change. Blender knows to only switch the value at the keyframe since there is no way to interpolate a boolean.
In the above example I have visibility keyframes at frames 1, 15, 30, and 40. Notice that I don't need keyframes at frames 14, 29, and 39 to make sure that it stays constant up until those frames.
As PGmath noted there is no need to do anything special for binary values.
Howerver, if you ever deal with values that are not binary, the "elegant" solution you need is setting the Interpolation Mode to Constant . That way there will be no values in between the ones set for the keyframes:
To access the interpolation options select the keyframes you want to affect and press T (or on the menu select Key->Interpolation)