Skip to content

Essential Keyboard Shortcuts ​

💡 TL;DR: Master these 15 shortcuts to double your daily productivity.

📝 Course Notes ​

Key takeaways from this lesson:

Essential shortcuts cheat sheet


What You'll Be Able to Do ​

  • Quickly create/switch sessions with shortcuts
  • One-key model and Agent switching
  • Quickly undo, redo, and copy messages
  • Navigate long conversations with page keys

Your Current Pain Points ​

  • Typing /new every time to create a new session
  • Typing /models to switch models
  • Not knowing how to undo operations
  • Slowly scrolling through long conversations

When to Use This ​

  • When you need to: work frequently in OpenCode
  • And don't want to: type commands every time

🎒 Prerequisites ​

Make sure you've completed the following:


Core Concepts ​

The Leader Key Mechanism (Important!) ​

OpenCode uses a Leader key (default Ctrl+X) as a shortcut prefix to avoid conflicts with terminal shortcuts.

🤔 What is a Leader Key?

A Leader key is similar to Vim's <Leader> or "combo keys" in games. It's not a function key itself, but a prefix key.

After pressing the Leader key, OpenCode waits for you to press a letter key. The combination forms a complete shortcut.

How to Use (Three-Step Method):

┌─────────────────────────────────────────────────────────────┐
│  Step 1           Step 2           Step 3                   │
│  Press Ctrl+X  →  Release all  →  Press letter (e.g. N)     │
│                                                             │
│  ⚠️ Key: Step 2 must release! Don't hold all three keys!    │
└─────────────────────────────────────────────────────────────┘

Examples:

What You WantCorrect OperationWrong Operation
New sessionPress Ctrl+X → Release → Press N❌ Press Ctrl+X+N simultaneously
Open session listPress Ctrl+X → Release → Press L❌ Hold Ctrl, press X then L
Switch modelPress Ctrl+X → Release → Press M❌ Press too fast without releasing

💡 Practice Tip

Initially, deliberately slow down: after pressing Ctrl+X, mentally count "1", then press the letter key. You'll naturally speed up with practice.

Selection Criteria ​

From 60+ shortcuts, selected based on:

  1. High frequency - Used almost daily
  2. Time-saving - Much faster than typing commands
  3. Easy to remember - Follows a pattern

15 Essential Shortcuts ​

🔥 Tier 1: Daily Essentials ​

These 8 are the most frequently used - memorize these first:

ShortcutFunctionNotes
EnterSend messageEnter to send
Shift+EnterNew line (don't send)Use when writing multi-line prompts
Ctrl+CClear input / Close dialog / ExitSee details below
EscapeInterrupt AI responsePress while AI is generating to stop immediately. Press twice to force interrupt
↑ / ↓Browse input historyWhen input is empty, use arrow keys to recall previous messages
TabSwitch AgentSwitch between Plan/Build/different Agents
Ctrl+X → NNew sessionLeader + N = New
Ctrl+X → LSession listLeader + L = List

💡 Multiple Ways to Create New Lines

Besides Shift+Enter, you can also use:

  • Ctrl+Enter
  • Alt+Enter
  • Ctrl+J

Just pick one that feels natural.

📦 Three Behaviors of Ctrl+C (v1.1.58 update)
  • When dialog is open: Close dialog (confirmations, selections, etc.)
  • When input has content: Clear input box (doesn't exit)
  • When input is empty: Exit OpenCode

⚠️ Note: Although both Ctrl+C and Ctrl+D can exit, their behaviors differ slightly. Ctrl+D sends a direct exit signal, while Ctrl+C first tries to clear the input. This matches terminal behavior that programmers are familiar with.

⚡ Tier 2: Productivity Boosters ​

These 5 significantly improve efficiency:

ShortcutFunctionMemory Tip
Ctrl+X → MModel listModel
F2Quick switch recent modelIDE standard
Ctrl+X → UUndo messageUndo
Ctrl+X → RRedo messageRedo
Ctrl+PCommand paletteSame as VS Code

🎯 Tier 3: Nice to Have ​

These 5 are useful in specific scenarios:

ShortcutFunctionUse Case
Ctrl+X → YCopy messageCopy AI response
Ctrl+X → CCompress contextWhen conversation is too long
Ctrl+X → BToggle sidebarView session tree
PageUp / PageDownPage navigationBrowse long conversations
Ctrl+X → TTheme listChange the look

🧑‍💻 For Programmers: Input Box Shortcuts ​

If you've used terminals or Emacs, these will be familiar:

ShortcutFunctionReadline Style
Ctrl+AJump to line start✅
Ctrl+EJump to line end✅
Ctrl+KDelete cursor to line end✅
Ctrl+UDelete cursor to line start✅
Ctrl+WDelete previous word✅
Alt+BBack one word✅
Alt+FForward one word✅
📦 What is Readline Style?

Readline is the standard input library for Unix/Linux terminals that defines a common set of shortcuts.

Almost all terminal programs (bash, zsh, python REPL) support these shortcuts. If you work in a terminal daily, these are already muscle memory.

OpenCode fully supports Readline, letting you edit text with familiar keystrokes.


Follow Along ​

Step 1: Practice Multi-line Input ​

Why
When writing multi-line prompts, you need to create new lines without sending.

  1. Type First line in the input box
  2. Press Shift+Enter
  3. Type Second line

You should see: Two lines of text in the input box, message not sent

⚠️ Common Issue

If Shift+Enter sends instead of creating a new line, your terminal doesn't support modifier keys. Solutions:

  • Use Ctrl+J instead (more universal)
  • Or refer to 5.6b Keybinds to configure your terminal

Step 2: Practice History Navigation ​

Why
Resend or modify previous messages without retyping.

  1. First send a message: Hello
  2. After AI replies, make sure the input box is empty
  3. Press ↑ (up arrow)

You should see: The input box automatically fills with Hello that you just sent

Continue pressing ↑ to browse older history, press ↓ to go to more recent messages.

Step 3: Practice Ctrl+C ​

Why
Quickly clear input, close dialogs, or exit OpenCode.

Scenario A - Clear Input:

  1. Type some text in the input box
  2. Press Ctrl+C

You should see: Input box is cleared

Scenario B - Close Dialog:

  1. Trigger a dialog (e.g., press Ctrl+X → L to open session list)
  2. Press Ctrl+C

You should see: Dialog closes, returns to normal conversation interface

Scenario C - Exit Application:

  1. Make sure input box is empty and no dialog is open
  2. Press Ctrl+C

You should see: OpenCode exits

Step 4: Practice Leader Key Combinations ​

Why
This is OpenCode's core shortcut mechanism.

Important: This is a two-step operation, not simultaneous!

  1. Press Ctrl+X
  2. Release all keys (this step is crucial!)
  3. Press N

You should see: A new session is created

Try opening the session list:

  1. Press Ctrl+X
  2. Release
  3. Press L

You should see: Session list popup appears

Step 5: Practice Undo/Redo ​

Why
Retry when AI's response is unsatisfactory.

  1. Send a message to AI
  2. After AI replies, press Ctrl+X → U

You should see: The message and reply are undone

Press Ctrl+X → R to redo.

Step 6: Practice Interrupting Response ​

Why
Stop AI early when response is too long or going in the wrong direction.

  1. Send a complex question
  2. While AI is responding, press Escape

You should see: AI stops generating


Checklist ✅ ​

Must pass all to continue

  • [ ] Shift+Enter creates new line without sending
  • [ ] ↑ browses input history (when input is empty)
  • [ ] Ctrl+C clears input, closes dialogs
  • [ ] Ctrl+X → N creates new session (remember to release before pressing N)
  • [ ] Ctrl+X → L opens session list
  • [ ] Escape interrupts AI response

Common Pitfalls ​

SymptomCauseSolution
Shift+Enter sends instead of new lineTerminal doesn't send modifier keysUse Ctrl+J, or configure terminal
Ctrl+X then N does nothingPressed N without releasing Ctrl+XMust release first, then press N
Ctrl+X has no responseTerminal captured the keyCheck terminal settings, or try a different terminal
Ctrl+C is not copyUsed to clear input or exit, not copyTo copy, use Ctrl+X → Y or select with mouse then Ctrl+V
Up arrow doesn't show historyInput box is not emptyFirst clear input box (Ctrl+C), then press up arrow
Tab doesn't switch AgentPressed while in input modePress Escape to exit input, then press Tab
Ctrl+Z accidentally suspendsThought it was undo, actually suspends terminalOpenCode will pause, need to type fg in terminal to resume. Don't use for "undo"!

Quick Memory Rhyme ​

Enter sends, Shift for new line
Up arrow for history, Ctrl+C clears and exits
New is N, List is L, Model M remember well
Undo U, Redo R, Copy Y with ease
Escape interrupts fast
Tab switches Agents conveniently
Ctrl+Z will suspend, don't use for undo

Lesson Summary ​

You learned:

  1. New line technique: Shift+Enter for new line, Enter to send
  2. History navigation: When input is empty, ↑/↓ to browse history
  3. Ctrl+C: Close dialog / Clear input (has content) or Exit (empty)
  4. Leader key mechanism: Ctrl+X → Release → Letter key
  5. Session management: N (new), L (list), U (undo)
  6. Programmer bonus: Full Readline-style shortcut support

Want More? ​


Next Lesson Preview ​

Next we'll learn about Global Rules to make AI permanently remember your work preferences.

You'll learn:

  • Create rule files, no need to say "reply in English" every time
  • Difference between global rules vs project rules
  • Practical rule examples

Appendix: Source Code Reference ​

Click to expand source code locations

Last updated: 2026-01-13

FeatureFile PathLines
Default shortcutssrc/config/config.ts616-754
Shortcut parsingsrc/util/keybind.tsEntire file

Key Defaults (from config.ts):

  • input_submit = "return" - Send message (line 668)
  • input_newline = "shift+return,ctrl+return,alt+return,ctrl+j" - New line (lines 669-673)
  • input_clear = "ctrl+c" - Clear input (line 666)
  • app_exit = "ctrl+c,ctrl+d,<leader>q" - Exit application (line 617)
  • history_previous = "up" - Previous history (line 747)
  • history_next = "down" - Next history (line 748)
  • agent_cycle = "tab" - Switch Agent (line 663)
  • leader = "ctrl+x" - Leader key (line 616)
  • session_new = "<leader>n" - New session
  • session_list = "<leader>l" - Session list
  • model_list = "<leader>m" - Model list
  • messages_undo = "<leader>u" - Undo message
  • messages_redo = "<leader>r" - Redo message