Skip to content
easeweb
Search topics

Fields that submit on Enter during IME conversion

A shop's search box runs the search on any Enter keydown, so the Enter that confirms a Japanese conversion searches for a half-typed query.

WCAG 2.2
SC 2.1.1ASC 3.2.2A
Required by
Section 508 · EN 301 549 (EU)
Broken if (event.key === 'Enter') search(input.value);
The accessibility problem illustrated: Cognitive:I wasn't finished. Why did it search?
01

The problem

People typing Japanese or Chinese through an input method have their search run, or their message sent, while they are still typing it.

02

Try it

Type a word that needs converting with the Japanese input above the window, then press Enter in the field to search.

The Enter that confirms 傘 is meant for the IME. Watch whether the page searches on it, and what the page got. With a Japanese IME of your own, type in the field for real.

Broken Can you fix this?

BrokenEnter on keydown runs the search
Japanese input (simulated):

Linden Home

Ready for the rainy season

Umbrellas, boots and covers for every day.

Enter, as the page got it: none yet

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Let the form handle Enter, or skip the Enter that confirms a conversion.

  1. 1Submit a field from its form, or skip Enter while isComposing is true or keyCode is 229.
  2. 2Act on Enter on keydown, never on keyup.
  3. 3Test with a real IME, in Safari as well as Chrome.
Before Enter on keydown runs the search
<div role="search">  <label for="q">Search</label>  <input id="q" type="search"></div> <script>  const input = document.getElementById('q');  input.addEventListener('keydown', (event) => {    if (event.key === 'Enter') search(input.value);  });  function search(query) {    location.assign(`/search?q=${encodeURIComponent(query)}`);  }</script>
After

A form, so the browser decides

<form role="search" action="/search">  <label for="q">Search</label>  <input id="q" name="q" type="search"></form>

Why this fix: Use native HTML first

Fixing this with an AI coding assistant? Get this guide as Markdown, or get every guide in your coding agent.

04

Verify the fix

5 checks, no mouse.

Test with: Keyboard, Input method (IME), Screen reader

0 of 5 checked

Record the OS, browser, input method and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after a search, chat or form component changes.

Limits

This is a starting pattern, not a guarantee for every application. The example is one search field typed in Japanese; Chinese input methods confirm text in their own ways. Korean ones usually pass the Enter that ends a syllable on as an ordinary Enter, and reports differ on whether Safari sends it with keyCode 229 or 13, so the second fix may swallow an Enter a Korean typist meant; test Korean input in Safari if your customers use it. Phone keyboards send their own sequence of events, so test with the input methods your customers use. Rich text editors handle composition themselves and need their own testing. The snippets leave out the search itself.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

Keep this fixed as your code changes.

Turn guides like this into rules your coding agents and CI follow, then have the result retested with a keyboard and screen readers.

How retests work