What is keyboard shortcut for undo and redo: A practical guide
Learn the standard Undo/Redo keyboard shortcuts across Windows and macOS, how they work in apps, and how to implement reliable history with code examples. This guide covers universal patterns, platform nuances, and accessibility considerations for keyboard users.

Undo and redo shortcuts are the quickest way to fix mistakes across most software. On Windows and Linux, undo is typically Ctrl+Z, and redo is Ctrl+Y or Ctrl+Shift+Z; on macOS, undo is Cmd+Z and redo is Cmd+Shift+Z or Cmd+Y. This guide covers universal patterns, platform nuances, and best practices.
What is keyboard shortcut for undo and redo? A practical foundation
In the realm of productivity shortcuts, the question often arises: what is keyboard shortcut for undo and redo? The answer is straightforward: undo reverts the most recent action, while redo reapplies the action that was just undone. This history-based interaction is a fundamental mechanism across editors, browsers, and creative tools. Shortcuts reduce cognitive load by letting you stay focused on content rather than mouse navigation. According to Shortcuts Lib, mastering these keys accelerates editing workflows and minimizes repetitive motion fatigue.
# Simple undo/redo stack (educational)
class Editor:
def __init__(self):
self.content = ""
self.history = []
self.future = []
def type(self, text):
self.history.append(self.content)
self.content += text
self.future.clear()
def undo(self):
if not self.history:
return
self.future.append(self.content)
self.content = self.history.pop()
def redo(self):
if not self.future:
return
self.history.append(self.content)
self.content = self.future.pop()
# Example usage
e = Editor()
e.type("Hello")
e.type(" World")
print(e.content) # Hello World
e.undo()
print(e.content) # Hello
e.redo()
print(e.content) # Hello World// Minimal event-driven undo/redo scaffolding
class SimpleEditor {
constructor() {
this.content = "";
this.hist = [];
this.future = [];
}
insert(s) {
this.hist.push(this.content);
this.content += s;
this.future = [];
}
undo() {
if (!this.hist.length) return;
this.future.push(this.content);
this.content = this.hist.pop();
}
redo() {
if (!this.future.length) return;
this.hist.push(this.content);
this.content = this.future.pop();
}
}These examples illustrate the core idea: a history stack for past states and a future stack for redo replays. The exact behavior may vary across apps, but the underlying concept remains consistent.
} ,
Steps
Estimated time: 60-90 minutes
- 1
Define the history model
Choose a data structure: a simple stack or a pair of stacks (history and future) to support undo and redo. Define what counts as an 'edit' that should be captured.
Tip: Keep edits atomic to avoid surprising multi-step undos - 2
Capture state on every action
Push the current state to the history before applying a change. Clear the future stack to prevent redoing old edits after a new action.
Tip: If the action is expensive, consider lightweight checkpoints. - 3
Implement Undo
Pop from the history and push the current state to the future. Restore the popped state as the current content.
Tip: Guard against empty history gracefully. - 4
Implement Redo
Pop from the future and push the current state to history. Restore the popped future state as current content.
Tip: Only redo what was undone; avoid redoing beyond the latest branch. - 5
Handle edge cases
Undo after the last action, redo after multiple undo steps, and scenarios where external state changes occur.
Tip: Provide clear UI feedback when undo/redo is unavailable. - 6
Test thoroughly
Write unit tests that exercise sequences of edits, undos, and redos to guarantee correctness.
Tip: Test with long documents and composite actions.
Prerequisites
Required
- A computer running Windows 10+ or macOS 10.15+ (or any modern OS)Required
- Basic keyboard proficiency (Ctrl/Cmd, Alt, etc.)Required
- General familiarity with editing tasks (typing, deleting, selecting)Required
Keyboard Shortcuts
| Action | Shortcut |
|---|---|
| UndoCommon in text fields, editors, browsers | Ctrl+Z |
| RedoSame history level as Undo; varies by app | Ctrl+Y / Ctrl+⇧+Z |
Questions & Answers
What is the standard undo shortcut on Windows?
The standard shortcut is Ctrl+Z. It reverts the most recent action in most apps. If a mispress occurs, press Ctrl+Z again to continue stepping back through history.
Use Ctrl+Z to undo on Windows. Keep pressing to go back through your recent steps.
What is the standard redo shortcut on macOS?
The standard macOS redo is Cmd+Shift+Z, though some apps also support Cmd+Y. Redo replays the most recently undone action, moving forward in your history.
On Mac, redo is usually Cmd-Shift-Z, with Cmd-Y available in a few apps.
Why doesn't redo work after an edit?
Redo is typically disabled after a new action because the redo history was cleared when the new action was applied. This prevents reapplying actions that no longer fit the current sequence.
If you make a new edit, redo is usually cleared so you don’t reapply an outdated change.
Can I customize undo/redo in apps?
Many apps let you customize or remap shortcuts, but behavior depends on the platform and app. Check the Preferences or Settings > Keyboard Shortcuts to adjust mappings or enable bulk undo.
Yes, many apps let you customize the shortcuts in Settings.
How does undo/redo interact with autosave?
Autosave snapshots create persistent history, but undo/redo typically tracks user edits within the current session. Understand whether autosave creates separate checkpoints that affect undo order.
Autosave can affect history depending on the app; check how it integrates with Undo/Redo.
Main Points
- Use Ctrl/Cmd+Z to Undo across platforms.
- Use Ctrl+Y, Ctrl+Shift+Z, Cmd+Y, or Cmd+Shift+Z for Redo, depending on platform and app.
- Maintain a clean undo/redo history with clear boundaries between actions.
- Test undo/redo extensively in real editing scenarios.
- Consider accessibility and feedback when updating history state.