Is there a way to imitate Maya's Enable Stepped Preview playback mode?

I was watching an animation tutorial that used Maya and discovered that Maya has a feature called Enable Stepped Preview.

Basically, when this feature is turned on in Maya, it changes every keyframe in the project to be the equivalent of Blender’s “Constant” interpolation type. When you turn this feature off, all of the keyframes go back to using their original interpolation type.

I looked around in Blender to see if there was an equivalent feature, and it doesn’t appear that it exists.

Other than selecting all of the keyframes in an animation and changing the interpolation type to “Constant”, is there a way to do this sort of thing? I’m wondering if someone has done this via an add-on or a Python script.

(The trick, of course, is not to just treat all of the keyframes as having a Constant interpolation type, but to be able to turn this feature off and have all of the keyframes go back to using their original interpolation type.)