Skip to content

feat(Editor): add Mod+Enter to run code#183

Open
enkr1 wants to merge 1 commit into
NUSSOC:masterfrom
enkr1:cmd-enter-run
Open

feat(Editor): add Mod+Enter to run code#183
enkr1 wants to merge 1 commit into
NUSSOC:masterfrom
enkr1:cmd-enter-run

Conversation

@enkr1

@enkr1 enkr1 commented May 28, 2026

Copy link
Copy Markdown

Adds Cmd+Enter (Mac) / Ctrl+Enter (Windows/Linux) as an alternative shortcut to run the current file, matching the convention from Jupyter, Colab, and Replit. F5 still works.

Closes #182.

Notes

Capture phase + stopPropagation

Monaco binds Ctrl+Enter / Cmd+Enter to editor.action.insertLineAfter and calls stopPropagation after handling it, so the existing bubble-phase window keydown listener never fired when the editor had focus. The listener was switched to capture phase and adds stopPropagation so our handlers run before Monaco and Monaco's default action is suppressed.

F5 and Cmd+S share the same listener and are unaffected — F5 has no Monaco binding, and the default Cmd+S action is a no-op without a save provider.

Hotkey rendering

The button hint was changed from F5 to Mod+Enter. To render the Enter glyph consistently across systems, Hotkey was extended to accept ReactNode (not just string) as values, and an inline SVG return-arrow replaces the character. U+21A9 has an emoji presentation variant which renders as an emoji on some macOS font stacks, visually inconsistent with ⌘ ⌥ ⇧ ⌃.

Test plan

  • Cmd+Enter runs the current file when the editor has focus
  • No stray newline (Monaco's insertLineAfter suppressed)
  • F5 still runs
  • Cmd+S still saves
  • Run button click still runs
  • Run button hint displays ⌘↵ on Mac

Cmd+Enter (Mac) / Ctrl+Enter (Windows/Linux) now runs the current
file, matching the convention from Jupyter, Colab, and Replit. F5
continues to work as before.

The window keydown listener was switched to capture phase + adds
stopPropagation because Monaco binds Cmd+Enter to insertLineAfter
by default and calls stopPropagation, preventing bubble-phase
listeners from ever firing. Capture phase fires before Monaco, so
the Run action takes precedence.

Hotkey now accepts ReactNode in its key map so Enter can render as
a return-arrow SVG on Mac, replacing U+21A9 LEFTWARDS ARROW WITH
HOOK which has an emoji presentation variant on some font stacks.

Closes NUSSOC#182
@netlify

netlify Bot commented May 28, 2026

Copy link
Copy Markdown

Deploy Preview for charming-gumption-9f94be ready!

Name Link
🔨 Latest commit 476f1a4
🔍 Latest deploy log https://app.netlify.com/projects/charming-gumption-9f94be/deploys/6a17c5758c67f90007a6d1b3
😎 Deploy Preview https://deploy-preview-183--charming-gumption-9f94be.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR] instead of F5 to run, can we introduce cmd + enter to run?

1 participant