@@ -91,6 +91,7 @@ export class CommitBox extends React.Component<
91
91
title = "Enter a commit message description"
92
92
value = { this . state . description }
93
93
onChange = { this . _onDescriptionChange }
94
+ onKeyPress = { this . _onDescriptionKeyPress }
94
95
/>
95
96
< input
96
97
className = { commitButtonClass }
@@ -106,8 +107,6 @@ export class CommitBox extends React.Component<
106
107
107
108
/**
108
109
* Callback invoked upon clicking a commit message submit button.
109
- *
110
- * @param event - event object
111
110
*/
112
111
private _onCommitClick = ( ) : void => {
113
112
const msg = this . state . summary + '\n\n' + this . state . description + '\n' ;
@@ -145,14 +144,33 @@ export class CommitBox extends React.Component<
145
144
* ## Notes
146
145
*
147
146
* - Prevents triggering a `'submit'` action when hitting the `ENTER` key while entering a commit message summary.
147
+ * - Triggers the `'submit'` action when hitting `Ctrl` + `ENTER`
148
148
*
149
149
* @param event - event object
150
150
*/
151
- private _onSummaryKeyPress ( event : any ) : void {
152
- if ( event . which === 13 ) {
151
+ private _onSummaryKeyPress = ( event : React . KeyboardEvent ) : void => {
152
+ if ( event . key === 'Enter' ) {
153
153
event . preventDefault ( ) ;
154
+ if ( event . getModifierState ( 'Control' ) ) {
155
+ this . _onCommitClick ( ) ;
156
+ }
154
157
}
155
- }
158
+ } ;
159
+
160
+ /**
161
+ * Callback invoked upon a `'keypress'` event when entering a commit message description.
162
+ *
163
+ * ## Notes
164
+ *
165
+ * - Triggers the `'submit'` action when hitting `Ctrl` + `ENTER`
166
+ *
167
+ * @param event - event object
168
+ */
169
+ private _onDescriptionKeyPress = ( event : React . KeyboardEvent ) : void => {
170
+ if ( event . key === 'Enter' && event . getModifierState ( 'Control' ) ) {
171
+ this . _onCommitClick ( ) ;
172
+ }
173
+ } ;
156
174
157
175
/**
158
176
* Resets component state (e.g., in order to re-initialize the commit message input box).
0 commit comments