Intercepting Undo/Redo Actions in the Editor

How can we listen for Undo (Ctrl + Z) or Redo (Ctrl + Y) actions, perform our own custom logic, and then consume the Ctrl + Z action to prevent changes to the editor?