Skip to content

Commit d1a4a52

Browse files
Admin: Add Ctrl/Cmd+Enter keyboard shortcut to submit comment forms.
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.
1 parent e12ddb3 commit d1a4a52

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/js/_enqueues/admin/edit-comments.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,12 @@ window.commentReply = {
10461046
if ( e.type === 'keydown' && e.which === 27 && isContextMenuOpen ) {
10471047
isContextMenuOpen = false;
10481048
}
1049+
1050+
// Submit the comment when Ctrl+Enter (Windows/Linux) or Cmd+Enter (Mac) is pressed.
1051+
if ( e.type === 'keydown' && ( e.ctrlKey || e.metaKey ) && e.which === 13 && ! isComposing ) {
1052+
e.preventDefault();
1053+
commentReply.send();
1054+
}
10491055
} )
10501056
.on( 'keyup', function( e ) {
10511057
// Close on Escape unless Input Method Editors (IMEs) are in use or the context menu is open.

0 commit comments

Comments
 (0)