Go to: Synopsis. Return value. Related. Flags. MEL examples.

Synopsis

hotkey [-altModifier] [-autoSave boolean] [-commandModifier] [-ctrlModifier] [-ctxClient string] [-dragPress boolean] [-factorySettings] [-isModifier] [-keyShortcut string] [-name string] [-pressCommandRepeat boolean] [-releaseCommandRepeat boolean] [-releaseName string] [-shiftModifier] [-sourceUserHotkeys]

hotkey is undoable, queryable, and NOT editable.

This command sets the single-key hotkeys for the entire application.

Return value

None

In query mode, return type is based on queried flag.

Related

hotkeyCtx, hotkeySet

Flags

altModifier, autoSave, commandModifier, ctrlModifier, ctxClient, dragPress, factorySettings, isModifier, keyShortcut, name, pressCommandRepeat, releaseCommandRepeat, releaseName, shiftModifier, sourceUserHotkeys
Long name (short name) Argument types Properties
-altModifier(-alt) createquery
-autoSave(-as) boolean create
If set to true then the hotkeys will always be saved when you quit. If false then the hotkeys are not saved unless "savePrefs -hotkeys" is used.
-commandModifier(-cmd) create
The Command key must be pressed to get the hotkey. This is only available on systems which have a separate command key. Note that if menu item accelerator keys are being used (menuItem -ke/keyEquivalent), then the accelerator key settings override the hotkey settings.
-ctrlModifier(-ctl) createquery
The Ctrl key must be pressed to get the hotkey. Note that if menu item accelerator keys are being used (menuItem -ke/keyEquivalent), then the accelerator key settings override the hotkey settings.
-ctxClient(-cc) string createquery
Specifies the hotkey context. It is used together with the other flags to modify or query the hotkey for a certain hotkey context. If it is not specified, the global hotkey context will be taken into account. Check hotkeyCtx command to see how the hotkeys work with the hotkey contexts.
-dragPress(-dp) boolean create
Specify true and the command may be executed during manipulator dragging, if the tool context also allows this. This flag is false by default.
-factorySettings(-fs) create
Resets the hotkeys back to the initial defaults.
-isModifier(-mod) create
This flag is obsolete and should no longer be used.
-keyShortcut(-k) string create
Specify what key is being set. The key must be either a single ascii character (capital and lowercase can be set independently) or one of the keyword strings for the special keyboard characters.

The valid keywords are:
Up, Down, Right, Left,
Home, End, Page_Up, Page_Down, Insert
Return, Space
F1 to F12
Tab (Will only work when modifiers are specified)
Delete, Backspace (Will only work when modifiers are specified)

-name(-n) string createquery
The name of the namedCommand object that will be executed when the key is pressed.
-pressCommandRepeat(-pcr) boolean create
Specify true and the command may be repeated by executing the command repeatLast. This flag is false by default.
-releaseCommandRepeat(-rcr) boolean create
Specify true and the command may be repeated by executing the command repeatLast. This flag is false by default.
-releaseName(-rn) string createquery
The name of the namedCommand object that will be executed when the key is released.
-shiftModifier(-sht) createquery
The Shift key must be pressed to get the hotkey.
-sourceUserHotkeys(-suh) create
This flag is obsolete. Please use import flag from hotkeySet command to import the user hotkeys.


Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can be used more than once in a command.

MEL examples

// Here's an example of how to create a namedCommand
// object and then map it to a key.
//
nameCommand
    -annotation "Select Circle Tool"
    -command "setToolTo circleContext"
    circleToolNamedCommand;
hotkey -k "F5" -alt -name "circleToolNamedCommand";


// Here are more examples of how to use the hotkey command.
//
hotkey -k "d" -name "Delete_Command";
hotkey -k "d" -name "";  // unsets the above command

hotkey -k "d" -name "Delete_Command";
hotkey -k "d" -releaseName "After_Delete_Command";
hotkey -k "d" -name "";         //only unsets the key press name
hotkey -k "d" -releaseName "";  //only unsets the key release name
hotkey -k "d" -n "" -rn "";     //unsets both the key press and release name

//    Determine if a command is attached to either the press or release
//    of the "z" hotkey.
//
hotkey -query z;

//    Likewise, for the modified variations of the "z" key.
//
hotkey -query -alt z;
hotkey -query -ctl z;
hotkey -query -alt -ctl z;

//    Determine the press command attached to the "z" key.
//
hotkey -query -name z;

//    To query the "-" hotkey use the string "Dash" instead.
//
hotkey -query Dash;

//    Here's an example of how to create runtimeCommand with  a certain hotkey context,
//    and map it to a key.
//

//    Create a command with "paintEffects" hotkey context.
//
runTimeCommand
	-annotation "Modify the Brush Size for the Paint Effects Tool"
	-category "Paint Effects"
	-commandLanguage "mel"
	-command ("dynWireCtx -e -dbs \"width\" `currentCtx`;")
	-hotkeyCtx ("paintEffects")
	ModifyBrushSize;

nameCommand
	-annotation "ModifyBrushSizeNameCommand"
	-sourceType "mel"
	-command ("ModifyBrushSize")
	ModifyBrushSizeNameCommand;

//    Assign the paintEffects as a hotkey context client.
//
hotkeyCtx -type "Tool" -addClient "paintEffects";

//    Map a key to the newly created command.
//    When the Paint Effects Tool is activated, the b key will work within this tool and
//    override editor and application-wide contexts.
hotkey -keyShortcut "b" -name "ModifyBrushSizeNameCommand";

//    Determine the press command attached to the "b" key within the tool's context.
//
hotkey -query -ctxClient "paintEffects" -name b;

//    Unset the key press name within the tool's context
//
hotkey -k "b" -name "" -ctxClient "paintEffects";