このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

CommandEvent: command プロパティ

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.

commandCommandEvent インターフェイスの読み取り専用プロパティで、イベントが発信された時点での command プロパティの値を含む文字列を返します。

文字列です。

次の簡単な例では、"show-modal" コマンドを監視するイベントリスナーを設定しています。

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

    if (theAction === "show-modal") {
      console.log("モーダルダイアログを表示");
    }
  },
  { capture: true },
);

仕様書

Specification
HTML
# dom-commandevent-command

ブラウザーの互換性

関連情報