## VASSAL Reference Manual

Home > Module > Game Piece Palette > Game Piece > Named Key Commands

### Key Commands and Named Key Commands

Key Commands and Named Key Commands let Vassal know when to activate traits (e.g. when should a Clone trait make a copy of the piece, when should the Delete trait delete it, when should the Tank’s turret rotate, etc, etc). Key Commands: A traditional Key Command is simply the name of a keystroke, such as Ctrl+K or Alt+Shift+X. If a trait is assigned a traditional Key Command, then whenever the player presses that keystroke while the piece is selected, the trait will be activated. If the trait is also assigned a Menu Command string, then the keystroke for the Key Command will be displayed in the context menu for the piece as a shortcut. Named Key Commands: A Named Key Command, by contrast, can be any text message at least two characters long, such as FireForwardPhasers or EliminateUnit or SpinTurretRight. These names will not be displayed on screen during play, they are private to the module, and function much like naming a variable, method, or function in a programming language. If a Named Key Command is paired with a Menu Command string, then it will still generate an entry on the piece’s context menu, but no keystroke will be displayed. If the player then selects that menu item, the Named Key Command will "fire" and any trait in the piece with that Named Key Command assigned will be activated. Activating Key Commands and Named Key Commands: In addition to being activated when the player selects the corresponding menu item from the context menu, and (in the case of regular Key Commands) when the player presses the designated keystroke combination while the piece is selected, both types of Key Command can also be generated by a Trigger Action trait from the same piece, or by a Global Key Command from any piece. This allows module designers to chain several actions together to create sophisticated modules. Earlier versions of Vassal supported only traditional Key Commands (i.e. actual keystrokes), and so every aspect of a trait of any piece potentially needing to be activated had to be assigned its own keystroke. This quickly made the keyboard seem very crowded for designers of sophisticated modules! So the Named Key Command was introduced to allow modules more breathing room to create useful traits and commands. |