Skip to content

Trac 48536 admin add ctrl cmd enter shortcut#11486

Open
vidushigupta0607 wants to merge 2 commits intoWordPress:trunkfrom
vidushigupta0607:trac-48536-admin-add-ctrl-cmd-enter-shortcut
Open

Trac 48536 admin add ctrl cmd enter shortcut#11486
vidushigupta0607 wants to merge 2 commits intoWordPress:trunkfrom
vidushigupta0607:trac-48536-admin-add-ctrl-cmd-enter-shortcut

Conversation

@vidushigupta0607
Copy link
Copy Markdown

Problem

The WordPress admin comment reply/edit forms did not support the Ctrl+Enter / Cmd+Enter keyboard shortcut for submitting comments. While this convenient shortcut was available for frontend comment forms (added in ticket #41545), wp-admin users had to reach for the mouse to click the Submit button, creating an inconsistent experience across frontend and backend.

Root Cause

The root cause was that the comment reply/edit form handler in edit-comments.js lacked the necessary keyboard vent logic to detect and handle the Ctrl+Enter (Windows/Linux) or Cmd+Enter (Mac) key combination. While the file contained handlers for other keyboard interactions (Escape to cancel, Enter on text inputs), there was no support for the modifier+Enter pattern used to submit the textarea content.

Solution

Added keyboard event detection to the existing contextmenu keydown handler on the #replycontent textarea inside commentReply.open() in src/js/_enqueues/admin/edit-comments.js:

  // Submit the comment when Ctrl+Enter (Windows/Linux) or Cmd+Enter (Mac) is pressed.
  if ( e.type === 'keydown' && ( e.ctrlKey || e.metaKey ) && e.which === 13 && ! isComposing ) {
      e.preventDefault();
      commentReply.send();
  }

This addition:

  • Detects Ctrl+Enter (Windows/Linux) or Cmd+Enter (Mac) on the comment textarea
  • Respects IME (Input Method Editor) composition state to prevent accidental submissions during CJK input
  • Calls the existing commentReply.send() method to submit via AJAX
  • Prevents the default browser behavior to avoid inserting a newline

Example Usage

After this change, users can submit admin comment replies and edits using the keyboard shortcut:

  1. Click "Reply" or "Quick Edit" on a comment
  2. Type the comment text in the textarea
  3. Press Ctrl+Enter (Windows/Linux) or Cmd+Enter (Mac)
  4. Form submits immediately without requiring mouse interaction

Impact

This enhancement improves the WordPress admin user experience by providing keyboard-savvy users with a faster workflow for managing comments. The implementation maintains consistency with the frontend comment form behavior while following WordPress JavaScript coding standards and accessibility best practices (IME-aware composition detection).

Trac Link

https://core.trac.wordpress.org/ticket/48536

Allow submitting the comment reply/edit form in wp-admin with Ctrl+Enter (Windows/Linux) or Cmd+Enter (Mac), matching the existing frontend comment form behavior added in ticket #41545. The handler is added to the existing keydown event on the comment textarea, preventing listener stacking and respecting IME composition state.

Implements Trac #48536.
@vidushigupta0607 vidushigupta0607 force-pushed the trac-48536-admin-add-ctrl-cmd-enter-shortcut branch from 8a463c5 to 08e05a1 Compare April 9, 2026 05:13
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props vidugupta.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Add QUnit tests to verify the Ctrl+Enter / Cmd+Enter keyboard shortcut behavior on admin comment reply/edit forms. Tests cover:
- Ctrl+Enter submission (Windows/Linux)
- Cmd+Enter submission (Mac)
- Plain Enter does not submit
- IME composition state blocks submission
- Shift/Alt modifiers prevent submission
- Event type validation

Fixes Trac #48536
@vidushigupta0607 vidushigupta0607 force-pushed the trac-48536-admin-add-ctrl-cmd-enter-shortcut branch from 08e05a1 to 79f97da Compare April 9, 2026 18:56
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

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.

1 participant