diff --git a/packages/react-dom/src/events/__tests__/SyntheticKeyboardEvent-test.js b/packages/react-dom/src/events/__tests__/SyntheticKeyboardEvent-test.js
index c31912c3993c0..16fd4d757e28b 100644
--- a/packages/react-dom/src/events/__tests__/SyntheticKeyboardEvent-test.js
+++ b/packages/react-dom/src/events/__tests__/SyntheticKeyboardEvent-test.js
@@ -115,6 +115,47 @@ describe('SyntheticKeyboardEvent', () => {
);
expect(called).toBe(false);
});
+
+ it('when charCode is 10, returns 13', () => {
+ let charCode = null;
+ const node = ReactDOM.render(
+ {
+ charCode = e.charCode;
+ }}
+ />,
+ container,
+ );
+ node.dispatchEvent(
+ new KeyboardEvent('keypress', {
+ charCode: 10,
+ bubbles: true,
+ cancelable: true,
+ }),
+ );
+ expect(charCode).toBe(13);
+ });
+
+ it('when charCode is 10 and ctrl is pressed, returns 13', () => {
+ let charCode = null;
+ const node = ReactDOM.render(
+ {
+ charCode = e.charCode;
+ }}
+ />,
+ container,
+ );
+ node.dispatchEvent(
+ new KeyboardEvent('keypress', {
+ charCode: 10,
+ ctrlKey: true,
+ bubbles: true,
+ cancelable: true,
+ }),
+ );
+ expect(charCode).toBe(13);
+ });
});
// TODO: this seems IE8 specific.
diff --git a/packages/react-dom/src/events/getEventCharCode.js b/packages/react-dom/src/events/getEventCharCode.js
index dacf66714b4c4..0f2c3cd94ab39 100644
--- a/packages/react-dom/src/events/getEventCharCode.js
+++ b/packages/react-dom/src/events/getEventCharCode.js
@@ -31,6 +31,12 @@ function getEventCharCode(nativeEvent) {
charCode = keyCode;
}
+ // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux)
+ // report Enter as charCode 10 when ctrl is pressed.
+ if (charCode === 10) {
+ charCode = 13;
+ }
+
// Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
// Must not discard the (non-)printable Enter-key.
if (charCode >= 32 || charCode === 13) {