Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

command

The command event is executed when an element is activated.

How it is activated varies for each element and in many cases, there are several ways to activate an element. For example, a button can be activated by clicking on it with the mouse or by pressing SPACE while it has the focus. Menus can be activated by selecting them with the mouse or by pressing a shortcut key. Command elements can be activated by any of their observing elements being activated. The command event should always be used instead of the click event because it will be called in all of the needed cases.

General info

Specification
XUL
Interface
XULCommandEvent
Bubbles
Yes
Cancelable
Yes
Target
element
Default Action
None

Properties

sourceEvent Event The activation event that caused this command event to be generated. Currently only set when a command event is redirected though use of the command attribute.
Property Type Description
target Read only EventTarget The event target (the topmost target in the DOM tree).
type Read only DOMString The type of event.
bubbles Read only boolean Does the event normally bubble?
cancelable Read only boolean Is it possible to cancel the event?
view Read only WindowProxy document.defaultView (the window of the document).
detail Read only long (float) Unused; always zero.
ctrlKey Read only boolean true if the control key was down when the event was fired. false otherwise.
shiftKey Read only boolean true if the shift key was down when the event was fired. false otherwise.
altKey Read only boolean true if the alt key was down when the event was fired. false otherwise.
metaKey Read only boolean true if the meta key was down when the event was fired. false otherwise.

Example

menuitem.oncommand = function() {
  console.log("the menu item has been activated");
};

Document Tags and Contributors

 Contributors to this page: teoli, Sheppy, ethertank, Neil, louisremi
 Last updated by: teoli,