---
title: CompositionEvent()
slug: Web/API/CompositionEvent/CompositionEvent
tags:
  - API
  - CompositionEvent
  - Constructor
  - Reference
browser-compat: api.CompositionEvent.CompositionEvent
---
{{APIRef("DOM Events")}}

The **`CompositionEvent()`**
constructor creates a new {{domxref("CompositionEvent")}} object instance.

## Syntax

```js
const myEvent = new CompositionEvent(typeArg [, CompositionEventInit])
```

### Values

- `typeArg`
  - : Is a {{domxref("DOMString")}} representing the name of the event.
- `CompositionEventInit` {{optional_inline}}

  - : A `CompositionEventInit` dictionary object, which can contain the
    following members:

    - `data`
      - : Initializes the {{domxref("CompositionEvent.data", "data")}} attribute of the
        {{domxref("CompositionEvent")}} object to the characters generated by the IME
        composition.

    > **Note:** The `CompositionEventInit` dictionary inherits
    > from the {{domxref("UIEvent.UIEvent", "UIEventInit")}} dictionary, so can also
    > accept members defined on there.

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("CompositionEvent")}}, the interface of the objects it constructs.
