Go to: Synopsis. Return value. MEL examples.



getModifiers is undoable, NOT queryable, and NOT editable.

This command returns the current state of the modifier keys. The state of each modifier can be obtained by testing for the modifier's corresponding bit value in the return value. Shift is bit 1, Ctrl is bit 3, Alt is bit 4, and bit 5 is the 'Windows' key on Windows keyboards and the Command key on Mac keyboards. See the provided example for more details on testing for each modifier's bit value.

Return value

intindicating which modifier keys are pressed.

MEL examples

button -label "Press Me" -command "PrintModifiers";

global proc PrintModifiers()
    int $mods = `getModifiers`;
    print ("Modifiers are:");
    if ($mods % 2) print (" Shift");
    if ($mods / 4 % 2) print (" Ctrl");
    if ($mods / 8 % 2) print (" Alt");
    if ($mods / 16 % 2) print (" Command");
    print ("\n");