To associate a MEL script with a hotkey, you must first add the script to the list of available hotkey commands, then assign a hotkey to the command you created.
For example, type m in the text box and turn on the Alt setting to assign the marking menu to + m.
As you edit these settings, Maya shows the command currently assigned to the hotkey, if any. Only assign the hotkey if you don’t mind overriding this command.
The distinction between Press and Release can be important, for example when you assign a hotkey to a snapping mode. You want to assign the command to turns the snapping mode on to the key press, and the command that turns the snapping mode off to the key release.
If the hotkey you set already has a command assigned, Maya asks if you want to override it.
You can use the following MEL scripts to create toggles for x-ray and wire/shaded modes.
/MEL to toggle xray mode on/off
//map to a hotkey
//get the current panel as xray mode works per panel
$currentPanel = `getPanel -withFocus`;
//get the state of xray mode (either on or off)
$state = `modelEditor -q -xray $currentPanel`;
//set it to the opposite state
modelEditor -edit -xray (!$state) $currentPanel;
//MEL to toggle cameras and image planes on/off
//map to a hotkey
$currentPanel = `getPanel -withFocus`;
$state = `modelEditor -q -cameras $currentPanel`;
modelEditor -edit -cameras (!$state) $currentPanel;