Go to: Synopsis. Return value. Python examples.

Synopsis

getModifiers()

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

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.

Python examples

import maya.cmds as cmds

def PrintModifiers(*args):
    mods = cmds.getModifiers()
    print 'Modifiers are:'
    if (mods & 1) > 0: print ' Shift'
    if (mods & 4) > 0: print ' Ctrl'
    if (mods & 8) > 0: print ' Alt'
    if (mods & 16): print ' Command/Windows'

cmds.window()
cmds.columnLayout()
cmds.button( label='Press Me', command=PrintModifiers )
cmds.showWindow()