Go to: Synopsis. Return value. Flags. Python examples.
hotkeyCheck([altModifier=boolean], [commandModifier=boolean], [ctrlModifier=boolean], [keyString=string], [keyUp=boolean], [optionModifier=boolean])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
hotkeyCheck is undoable, NOT queryable, and NOT editable.
This command checks if the given hotkey is mapped to a nameCommand
object. If so, the annotation of the nameCommand object is returned.
Otherwise an empty string is returned.
string | Contains all clients name, each followed by the annotation of the corresponding nameCommand object, or
an empty string. |
altModifier, commandModifier, ctrlModifier, keyString, keyUp, optionModifier
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 have multiple arguments, passed either as a tuple or a list.
|
import maya.cmds as cmds
# Create a window in which you can type a hotkey character
# and determine via the 'hotkeyCheck' command the annotation
# of the command attached.
#
window = cmds.window( title='hotkeyCheck Example' )
cmds.columnLayout( adjustableColumn=True )
# A few instructions in a scrollField for the user.
#
instructions = "Enter a single character in the field below. \
Then press the 'Query' button to determine the annotation of the command attached to that hotkey."
cmds.scrollField( text=instructions, editable=False, height=120, wordWrap=True )
textFieldGrp = cmds.textFieldGrp( label="Enter a single hotkey character", text='a', columnWidth2=(200, 50) )
# Create a couple controls for specifying modifier keys and the
# key press/release information.
#
checkBoxGrp = cmds.checkBoxGrp( label="Modifiers",
numberOfCheckBoxes=2,
labelArray2=('Ctrl', 'Alt'),
columnWidth3=(100, 75, 75))
radioButtonGrp = cmds.radioButtonGrp( label="Action",
numberOfRadioButtons=2,
select=1,
labelArray2=('Press', 'Release'),
columnWidth3=(100, 75, 75))
# Create a scroll field for printing the results.
#
scrollField = cmds.scrollField(editable=False, height=120, wordWrap=True)
# Create a button for querying the hotkey.
#
cmds.button( label='Query', command=('ExampleHotkeyCheck("' + textFieldGrp + '","' + checkBoxGrp + '","' + radioButtonGrp + '","' + scrollField + '")'))
cmds.showWindow( window )
# This procedure uses the 'hotkeyCheck' command to determine the
# annotation of the command attached to a hotkey.
#
def ExampleHotkeyCheck( textFieldGrp, checkBoxGrp, radioButtonGrp, scrollField):
# Get the hotkey character, modifier state and key press/release
# information from the window.
#
key = cmds.textFieldGrp(textFieldGrp, query=True, text=True)
ctrl = cmds.checkBoxGrp(checkBoxGrp, query=True, value1=True)
alt = cmds.checkBoxGrp(checkBoxGrp, query=True, value2=True)
press = cmds.radioButtonGrp(radioButtonGrp, query=True, select=True)
# Get the hotkey mapping taking into consideration key up or down
# and the state of the modifier keys.
#
if 1 == press:
if not ctrl and not alt:
mapping = cmds.hotkeyCheck(keyString=key)
result = key + '-Press'
elif ctrl and not alt:
mapping = cmds.hotkeyCheck(keyString=key, ctl=True)
result = 'Ctrl-' + key + '-Press'
elif not ctrl and alt:
mapping = cmds.hotkeyCheck(keyString=key, alt=True)
result = 'Alt-' + key + '-Press'
elif ctrl and alt:
mapping = cmds.hotkeyCheck(keyString=key, ctl=True, alt=True)
result = 'Ctrl-Alt-' + key + '-Press'
else:
if not ctrl and not alt:
mapping = cmds.hotkeyCheck(keyString=key, keyUp=True)
result = key + '-Release'
elif ctrl and not alt:
mapping = cmds.hotkeyCheck(keyString=key, ctl=True, keyUp=True)
result = 'Ctrl-' + key + '-Release'
elif not ctrl and alt:
mapping = cmds.hotkeyCheck(keyString=key, alt=True, keyUp=True)
result = 'Alt-' + key + '-Release'
elif ctrl and alt:
mapping = cmds.hotkeyCheck(keyString=key, ctl=True, alt=True, keyUp=True)
result = 'Ctrl-Alt-' + key + '-Release'
# Print the results in the example window.
#
if mapping == "": mapping = 'Nothing'
cmds.scrollField( scrollField, edit=True, text=(result + ' is mapped to:\n\n' + mapping ) )