CommandEvent: command property

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 command read-only property of the CommandEvent interface returns a string containing the value of the command property at the time the event was dispatched.

Value

A string.

Examples

In the following simple example we've set up an event listener to listen for the "show-modal" command:

js
document.body.addEventListener(
  "command",
  (event) => {
    const theAction = event.command;

    if (theAction === "show-modal") {
      console.log("Showing modal dialog");
    }
  },
  { capture: true },
);

Specifications

Specification
HTML
# dom-commandevent-command

Browser compatibility

See also