public static UndoRedoKeeper installUndoRedo(JTextComponent textComponent) {

		Document document = textComponent.getDocument();
		final UndoRedoKeeper undoRedoKeeper = new UndoRedoKeeper();
		document.addUndoableEditListener(e -> {
			UndoableEdit edit = e.getEdit();
			undoRedoKeeper.addUndo(edit);
		});

		// need a key listener
		textComponent.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent e) {
				KeyStroke keyStrokeForEvent = KeyStroke.getKeyStrokeForEvent(e);
				if (REDO_KEYSTROKE.equals(keyStrokeForEvent)) {
					undoRedoKeeper.redo();
					e.consume(); // consume to prevent other listeners from processing a second time
				}
				else if (UNDO_KEYSTROKE.equals(keyStrokeForEvent)) {
					undoRedoKeeper.undo();
					e.consume(); // consume to prevent other listeners from processing a second time
				}
			}
		});

		return undoRedoKeeper;
	}
Installs key binding support for undo/redo operations on the given text component.

<p>Note: the edits are tracked by adding a listener to the document of the given text
component.  If that document is changed,  then undo/redo will stop working.

@param textComponent the text component
@return the object that allows the client to track the undo/redo state
Ghidra/Framework/Docking/src/main/java/docking/DockingUtils.java