Keyboard Shortcut for Undo on Mac
An educational technical guide exploring the macOS undo shortcut (Cmd+Z), cross-app consistency, and practical patterns for developers building undo-capable tools.

The keyboard shortcut for undo on mac is Command+Z. This standard shortcut works across most macOS apps to reverse the most recent action. In some applications you can redo with Command+Shift+Z, or use the Edit > Undo menu if needed. If an app uses a custom shortcut, check its Edit menu or Preferences to confirm.
Understanding Undo on macOS: A Primer
According to Shortcuts Lib, the keyboard shortcut for undo on mac is the standard Command+Z. This shortcut works across most macOS apps to reverse the most recent action. In some apps you can redo with Command+Shift+Z, or with the Edit menu option Edit > Undo. If an app uses a custom shortcut, verify in the app's Settings or Edit menu to confirm. This section provides a solid foundation for how undo behaves across the macOS ecosystem and why Cmd+Z remains the default for most users.
# Simple Undo manager in Python
class UndoStack:
def __init__(self):
self.stack = []
def do(self, action):
self.stack.append(action)
def undo(self):
if not self.stack:
return None
return self.stack.pop()
# Example usage
state = []
un = UndoStack()
un.do("type A")
state.append("A")
un.do("type B")
state.append("B")
print("State before undo:", state)
state.pop()
print("After undo:", state)/* Simple web-based text editing undo history */
let history = [];
let current = "";
function setValue(next) {
history.push(current);
current = next;
render(next);
}
function undo() {
if (history.length === 0) return;
current = history.pop();
render(current);
}
document.addEventListener('keydown', (e) => {
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'z') {
e.preventDefault();
undo();
}
});
function render(text) { document.getElementById('display').textContent = text; }-- AppleScript: Trigger Undo in frontmost app
tell application "System Events"
keystroke "z" using {command down}
end tellLine-by-line breakdown:
- The Python example shows a minimal UndoStack to push actions and pop for undo.
- The JavaScript example demonstrates a simple history array with a handler that binds Cmd/Ctrl+Z to undo in a web editor.
- The AppleScript demonstrates how you could programmatically trigger Undo in the currently focused macOS app, useful for automation.
Common variations:
- Some apps provide multiple levels of Undo; some limit to last action. Always test with your target app to see exact behavior.
Steps
Estimated time: 15-25 minutes
- 1
Identify the action to undo
Perform a typical edit in your target app and prepare to undo. Verify the result you expect to reverse. This ensures your undo trail is meaningful.
Tip: Practice with simple edits to build muscle memory. - 2
Use the standard shortcut
Press Cmd+Z to undo. If the app supports redo immediately, try Cmd+Shift+Z or Cmd+Y as a fallback.
Tip: Keep your hands near the keyboard for speed. - 3
Try multiple undos
Repeat Cmd+Z to go back through several actions. In some apps, redo can reapply undone steps.
Tip: Be mindful of operations that reset history. - 4
Check app-specific behavior
Some apps switch undo behavior after certain edits; consult the Edit menu for the exact shortcut.
Tip: When in doubt, use the menu to confirm. - 5
Test redo as needed
Use Cmd+Shift+Z to redo last undone action, if supported by the app.
Tip: Redo works best when you’re confident about your previous state. - 6
Document edge cases
Note any app-specific quirks for future reference or training material.
Tip: Create a quick cheatsheet for frequent apps.
Prerequisites
Required
- macOS on a modern Mac (latest two major versions recommended)Required
- Basic macOS keyboard proficiency (Command key, modifiers)Required
- Familiarity with the Edit menu and application behaviorRequired
- A text editor or app where Undo is expected to workRequired
Keyboard Shortcuts
| Action | Shortcut |
|---|---|
| UndoMost apps; single-step undo | Ctrl+Z |
| RedoMost apps; redo the last undone action | Ctrl+⇧+Z |
Questions & Answers
What is the standard keyboard shortcut for undo on mac?
The standard shortcut is Cmd+Z. It undoes the most recent action in most macOS apps. If an app uses a different scheme, check the Edit menu.
Cmd+Z is the universal Mac undo shortcut; most apps follow this, but some may differ.
Is Cmd+Z universal across all apps, including text editors and graphics tools?
Cmd+Z covers most apps on macOS, but some specialized tools use extended undo or shortcuts for specific actions. Always verify in the app's help or Edit menu.
Cmd+Z works in most apps, but not every app follows the exact same rule.
Can I customize undo shortcuts on macOS?
Some apps let you customize shortcuts for undo and redo, but macOS itself does not provide a universal system-wide undo shortcut customization. Check each app's keyboard settings.
Customizing undo shortcuts is app-specific, not universal.
Does the Terminal or shell have a comparable undo feature?
Terminal sessions don’t have a universal undo. You undo within a shell or editor; the feature depends on the tool you’re using (e.g., text editor or command-line editor).
Terminal undo depends on the tool you’re using.
What about redo on macOS?
Redo is usually Cmd+Shift+Z on macOS apps, matching the Undo shortcut when supported. Some apps use Cmd+Z twice or other patterns for redo.
Redo is typically Cmd+Shift+Z on Mac.
Why might Undo not work after a save?
Saving or closing can clear the undo history in many apps, making undos unavailable for earlier states. Always consider the app’s save behavior when planning edits.
Undo history can be cleared by saving.
Main Points
- Remember Cmd+Z is the standard macOS undo shortcut.
- Redo is typically Cmd+Shift+Z across apps.
- App-specific variations exist; check menus to confirm.
- Practice with a small editor to build reliable habits.