Skip to content

Add Ctrl+Enter / Cmd+Enter shortcut to trigger Run tests #175

Description

@SkyDrive2

Problem Description

Currently, running tests requires manually moving the cursor and clicking the "Run tests" button with the mouse (web/interview.js:517):

nodes.run.addEventListener("click", runTests);

In mainstream competitive programming and interview platforms (e.g., LeetCode, HackerRank), candidates heavily rely on Ctrl+Enter (Windows/Linux) or Cmd+Enter (macOS) to run tests without taking their hands off the keyboard.

Furthermore, as noted in #131, the "Run tests" button can sometimes wrap or become awkward to click on narrower viewport widths. Having a standard keyboard shortcut significantly reduces interaction friction during timed interviews.

Proposed Changes
In web/interview.js, update the editor's keydown listener (line 581):

nodes.editor.addEventListener("keydown", (event) => {
  // Trigger Run tests with Ctrl+Enter or Cmd+Enter
  if ((event.ctrlKey || event.metaKey) && event.key === "Enter") {
    event.preventDefault();
    if (!nodes.run.disabled) {
      runTests();
    }
    return;
  }
  // existing Tab/Escape handling...
});

Update the button tooltip/title attribute in web/interview.html (line 171):

<button id="run-tests" class="run-button" type="button" title="Run tests (Ctrl+Enter / ⌘Enter)">
  Run tests
</button>

Expected Value
Matches mainstream interview and competitive programming editor ergonomics.
Allows candidates to focus on problem-solving without frequent context switching between keyboard and mouse.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions