CommandEvent: CommandEvent() constructor

Baseline 2025
Newly available

Since December 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

The CommandEvent() constructor creates a new CommandEvent object.

Syntax

js
new CommandEvent(type)
new CommandEvent(type, options)

Parameters

type

A string with the name of the event. It is case-sensitive and browsers set it to command.

options Optional

An object that, in addition of the properties defined in Event(), can have the following properties:

source Optional

An HTMLButtonElement representing the button that was interacted with to cause this event. This can be any element but we recommend only using button as a source to avoid surprises.

command Optional

A string containing the command for the controlled element to take. While manually instantiating a CommandEvent it is possible to use any string value, but it is recommended to use one of the built-in names or prefix with two dashes (--) to ensure forward compatibility.

Return value

A new CommandEvent object.

Specifications

This feature does not appear to be defined in any specification.

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
CommandEvent() constructor
Chrome – Full support
Chrome 135 (Release date: 2025-04-01)
footnote Full support
Edge – Full support
Edge 135 (Release date: 2025-04-04)
footnote Full support
Firefox – Full support
Firefox 144 (Release date: 2025-10-14)
footnote Full support
Opera – Full support
Opera 120 (Release date: 2025-07-02)
footnote Full support
Safari – Full support
Safari 26.2 (Release date: 2025-12-12)
footnote Full support
Chrome Android – Full support
Chrome Android 135 (Release date: 2025-04-01)
footnote Full support
Firefox for Android – Full support
Firefox for Android 144 (Release date: 2025-10-14)
footnote Full support
Opera Android – Full support
Opera Android 89 (Release date: 2025-04-29)
footnote Full support
Safari on iOS – Full support
Safari on iOS 26.2 (Release date: 2025-12-12)
footnote Full support
Samsung Internet – Full support
Samsung Internet 29 (Release date: 2025-10-25)
footnote Full support
WebView Android – Full support
WebView Android 135 (Release date: 2025-04-01)
footnote Full support
WebView on iOS – Full support
WebView on iOS 26.2 (Release date: 2025-12-12)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also