CommandEvent: command property

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

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

No specification found

No specification data found for api.CommandEvent.command.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

Browser compatibility

BCD tables only load in the browser

See also