# wrIsComposing

> True while an input method (IME) is composing, so the key belongs to it and not to your handler.

Source: https://ngwr.dev/reference/utils/wr-is-composing  
Kind: Util  
Updated in v16  
Optional

## Usage

Return early on it in every `keydown` handler that reads Enter, Escape or the arrows over a text field.

```angular-ts
import { wrIsComposing } from 'ngwr/utils';

onKeydown(event: KeyboardEvent): void {
  if (wrIsComposing(event)) return;

  switch (event.key) {
    case 'Enter': this.commit(); break;
    case 'Escape': this.close(); break;
  }
}
```

## Knowing the state between events

It is for `keydown` only; in an `input` or `blur` handler, track `compositionstart` and `compositionend` instead.

```angular-ts
@Component({
  host: {
    '(compositionstart)': 'composing = true',
    '(compositionend)': 'composing = false; onSettledInput()',
    '(input)': 'composing ? null : onSettledInput()',
  },
})
```

## API

| Name | Description | Type | Default |
| --- | --- | --- | --- |
| `wrIsComposing(event)` | True while an input method is composing. | `(e: KeyboardEvent) => boolean` | `—` |

## See also

- [Keyboard](https://ngwr.dev/guides/keyboard) — Bind shortcuts, show them as keycaps, and see which keys each component handles.
- [wrHasModifier](https://ngwr.dev/reference/utils/wr-has-modifier) — True when Ctrl, Cmd, Alt, Shift or Meta is held during a KeyboardEvent.
- [wrIsPrintableKey](https://ngwr.dev/reference/utils/wr-is-printable-key) — True for a single printable character typed without Ctrl, Cmd or Alt (Shift is allowed).
- [WR_KEYS](https://ngwr.dev/reference/utils/wr-keys) — KeyboardEvent.key constants, the WrKey union of their values, and WR_KEY_LABELS, what each key is called on a keycap.
