Skip to content

Conversation

@manzt
Copy link
Contributor

@manzt manzt commented Dec 26, 2025

On macOS, users coming from Jupyter and Colab may expect Ctrl-Enter to run cells, since those tools use Ctrl as the modifier key regardless of platform. Previously, only Cmd-Enter worked in marimo on macOS.

There are two separate systems handling keyboard shortcuts in marimo:

  1. Event handlers that use parseShortcut() to match keyboard events against shortcut strings. These check event properties like metaKey and ctrlKey directly.

  2. CodeMirror's keymap system, which has its own string-based key parsing. When we pass Cmd-Enter to CodeMirror, it only matches the Command key.

The previous implementation added withCtrlEquivalents() which duplicated all Cmd-based keybindings to also accept Ctrl on macOS. This was too broad and risked conflicts with CodeMirror's built-in Ctrl shortcuts (Ctrl-D for selection, Ctrl-K for line operations, etc.).

The fix narrows the scope: only run-related cell actions (cell.run and cell.runAndNewAbove) get Ctrl equivalents. These are the shortcuts that Jupyter and Colab users expect to work with Ctrl-Enter. Other cell keymaps like format, hide code, and focus navigation remain Cmd-only.

@manzt manzt requested a review from Light2Dark as a code owner December 26, 2025 18:51
@vercel
Copy link

vercel bot commented Dec 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jan 7, 2026 4:37am

@mscolnick
Copy link
Contributor

On macOS, users coming from Jupyter and Colab may expect Ctrl-Enter to run cells, since those tools use Ctrl as the modifier key regardless of platform. Previously, only Cmd-Enter worked in marimo on macOS.

Does it make sense to just map this keyboard shortcut specifically? Instead of duplicating all Cmd to Ctrl? This feels like there will be other undesired behavior as a result.

This is a good starting point to see if there are potential conflicts: https://github.com/search?q=org%3Acodemirror+language%3ATypeScript+Ctrl&type=code

@manzt
Copy link
Contributor Author

manzt commented Dec 26, 2025

Does it make sense to just map this keyboard shortcut specifically?

I believe there are more mappings beyond running cells (e.g., actions like split cell), but I see the conflict now with others beyond that (builtin to codemirror). Maybe the right idea would be to expand all our cell-specific keymaps? cc: @akshayka

@akshayka
Copy link
Contributor

I like the idea of scoping to cell-specific if that does not introduce conflicts

On macOS, users coming from Jupyter and Colab may expect `Ctrl-Enter` to
run cells, since those tools use `Ctrl` as the modifier key regardless
of platform. Previously, only `Cmd-Enter` worked in marimo on macOS.

There are two separate systems handling keyboard shortcuts in marimo:

1. Event handlers that use `parseShortcut()` to match keyboard events
   against shortcut strings. These check event properties like `metaKey`
   and `ctrlKey` directly.

2. CodeMirror's keymap system, which has its own string-based key
   parsing. When we pass `Cmd-Enter` to CodeMirror, it only matches
   the Command key.

The fix addresses both: `parseShortcut()` now normalizes "cmd" to "mod"
(which accepts either modifier), and `withCtrlEquivalents()` duplicates
`Cmd` keybindings with `Ctrl` variants for CodeMirror. The cell editor
keymaps use this wrapper so `Ctrl-Enter` runs cells just like
`Cmd-Enter`.
The previous implementation added `withCtrlEquivalents()` which
duplicated all Cmd-based keybindings to also accept Ctrl on macOS. This
was too broad and risked conflicts with CodeMirror's built-in Ctrl
shortcuts (Ctrl-D for selection, Ctrl-K for line operations, etc.).

The fix narrows the scope: only run-related cell actions (`cell.run` and
`cell.runAndNewAbove`) get `Ctrl` equivalents. These are the shortcuts
that Jupyter and Colab users expect to work with Ctrl-Enter. Other cell
keymaps like format, hide code, and focus navigation remain Cmd-only.
Light2Dark
Light2Dark previously approved these changes Dec 30, 2025
manzt added 2 commits January 6, 2026 14:12
Rename `withCtrlEquivalent` to `duplicateWithCtrlModifier` and skip
duplication when the binding already contains Ctrl. Adds test coverage.
@manzt
Copy link
Contributor Author

manzt commented Jan 7, 2026

This should be ready to go i think.

@manzt manzt merged commit fb111ab into main Jan 7, 2026
29 checks passed
@manzt manzt deleted the push-pzpyluyznnpl branch January 7, 2026 20:25
@github-actions
Copy link

github-actions bot commented Jan 7, 2026

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.18.5-dev171

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bash-focus Area to focus on during release bug bash enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants