---
title: "Enter submits half-typed text: reproduce IME composition | Proofline"
description: "Users who type Japanese, Chinese, Korean and many other languages compose characters with an input method editor (IME)."
url: https://proofline.sh/learn/ime-composition-enter-key/
---

[Learning center](/learn/)

# Enter submits half-typed text: reproduce IME composition

Users who type Japanese, Chinese, Korean and many other languages compose characters with an input method editor (IME). They press Enter to confirm the characters, not to submit. A search box or chat field that submits on every Enter keydown sends their unfinished text. Developers who type only with a Latin keyboard never see it. The bug replays on any machine once you know what the keydown carries.

Schema conflicts The Proofline team November 22, 2026 3 min read

## What the browser sends during composition

While a composition is active, key events carry a flag. In a keydown fired during composition, `event.isComposing` is `true`, and in Chromium `event.keyCode` is `229`. [MDN: `KeyboardEvent.isComposing`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/isComposing) · [MDN: `compositionstart`](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionstart_event)

We reproduced it in Chromium through the DevTools Protocol, without an IME installed. We started a composition of `にほん` in an input, then sent an Enter key with the virtual key code 229. The input's keydown listener logged:

```
keydown key=Enter isComposing=true keyCode=229
```

A handler written as `if (e.key === 'Enter') submit()` counted it as a submit.

## Reproduce it

**With a real IME.** Add a Japanese input source in the operating system's keyboard settings, type `nihon` in the field and press Enter once to confirm. If the form submits, or the field clears, the bug is there. This is the strongest evidence and needs no code.

**With the DevTools Protocol** in Playwright and Chromium:

```
const cdp = await page.context().newCDPSession(page);
await page.focus('#search');
await cdp.send('Input.imeSetComposition', { text: 'にほん', selectionStart: 3, selectionEnd: 3 });
await cdp.send('Input.dispatchKeyEvent', { type: 'rawKeyDown', key: 'Enter', code: 'Enter', windowsVirtualKeyCode: 229 });
await cdp.send('Input.insertText', { text: 'にほん' }); // commits the composition
```

[Protocol: `Input.imeSetComposition`](https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-imeSetComposition)

**With a synthetic event** in a unit test, to check only the handler's logic:

```
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', isComposing: true, bubbles: true }));
```

The order of events differs between browsers and operating systems. Safari, for example, has been reported to fire the confirming keydown after `compositionend`, where `isComposing` is already `false`. Test in the browser the reporter used.

## The usual fix, and its edge

Ignore Enter while composing:

```
input.addEventListener('keydown', e => {
  if (e.key === 'Enter' && !e.isComposing && e.keyCode !== 229) submit();
});
```

The `keyCode` check covers browsers that fire the confirming keydown with `isComposing` already false. Some editors also track `compositionstart` and `compositionend` and ignore Enter until a short moment after composition ends.

## What to put in the report

-   The language and input method, such as "Japanese, macOS Kotoeri, Romaji input"
-   The OS and browser versions
-   The exact keys: "type `nihon`, press Enter once to confirm"
-   What happened: submitted `にほn`, submitted nothing, or cleared the field

## Worked example: a chat that sent fragments

This example is fictional. Japanese-speaking users of a support chat report that messages arrive cut off, as if sent halfway through a word. Nobody on the team can reproduce it.

A tester adds the Japanese input source, types `arigatou`, and presses Enter to confirm the conversion. The chat sends `ありがとu` immediately. The team then writes the DevTools Protocol version as an automated test, which fails the same way. The chat's keydown handler submitted on any Enter. Adding the composition check fixed it, and the protocol test now runs in CI.

## Questions

### Does this affect only East Asian languages?

No. Any input method that composes characters, including some for Vietnamese and some accent input methods, can produce composition events.

### Does Playwright's `keyboard.press('Enter')` reproduce it?

No. It sends a normal Enter without a composition. Use the protocol calls or a real IME.

### Are mobile keyboards affected?

Mobile keyboards often compose text even for Latin languages, for autocorrect and suggestions, and some report `keyCode` 229 for many keys. Test on the device when the report comes from a phone.

Return to [reproducing what someone else saw](/learn/replay-browser-bug-report/) for the other layers a replay needs.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Input that fails only for some text: report the code points](/learn/unicode-input-bug/)
    
    Schema conflicts The Proofline team November 22, 2026 3 min read
    
-   ### [Typed text works but pasted text fails: capture the clipboard payload](/learn/pasted-text-bug/)
    
    Schema conflicts The Proofline team November 22, 2026 3 min read
