pymel.core.windows.hotkeyCheck

hotkeyCheck(*args, **kwargs)

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.

Flags:
Long name (short name) Argument Types Properties
altModifier (alt) bool ../../../_images/create.gif
 
Specifies if the Alt key is pressed.
commandModifier (cmd) bool ../../../_images/create.gif
 
Specifies if the command key is pressed.
ctrlModifier (ctl) bool ../../../_images/create.gif
 
Specifies if the Ctrl key is pressed.
isRepeatable (ir) bool  
   
keyString (k) unicode ../../../_images/create.gif
 
The key to check.
keyUp (kup) bool ../../../_images/create.gif
 
Specifies if the hotkey is on keyup or keydown (i.e. Release or Press). Flag can have multiple arguments, passed either as a tuple or a list.
optionModifier (opt) bool ../../../_images/create.gif
 
Specifies if the option key is pressed.
toBeRemovedInFutureMayaRelease (key) unicode  
   

Derived from mel command maya.cmds.hotkeyCheck

Example:

import pymel.core as pm

#    Create a window in which you can type a hotkey character
#    and determine via the 'hotkeyCheck' command the annotation
#    of the command attached.
#
window = pm.window( title='hotkeyCheck Example' )
pm.columnLayout( adjustableColumn=True )
# Result: ui.ColumnLayout('window1|columnLayout43') #

#    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."

pm.scrollField( text=instructions, editable=False, height=120, wordWrap=True )
textFieldGrp = pm.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 = pm.checkBoxGrp( label="Modifiers",
                                                    numberOfCheckBoxes=2,
                                                    labelArray2=('Ctrl', 'Alt'),
                                                    columnWidth3=(100, 75, 75))
radioButtonGrp = pm.radioButtonGrp( label="Action",
                                                    numberOfRadioButtons=2,
                                                    select=1,
                                                    labelArray2=('Press', 'Release'),
                                                    columnWidth3=(100, 75, 75))

#    Create a scroll field for printing the results.
#
scrollField = pm.scrollField(editable=False, height=120, wordWrap=True)

#    Create a button for querying the hotkey.
#
pm.button( label='Query', command=('ExampleHotkeyCheck("' + textFieldGrp + '","' + checkBoxGrp + '","' + radioButtonGrp + '","' + scrollField + '")'))
pm.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 = pm.textFieldGrp(textFieldGrp, query=True, text=True)
    ctrl = pm.checkBoxGrp(checkBoxGrp, query=True, value1=True)
    alt = pm.checkBoxGrp(checkBoxGrp, query=True, value2=True)
    press = pm.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 = pm.hotkeyCheck(keyString=key)
                    result = key + '-Press'
            elif ctrl and not alt:
                    mapping = pm.hotkeyCheck(keyString=key, ctl=True)
                    result = 'Ctrl-' + key + '-Press'
            elif not ctrl and alt:
                    mapping = pm.hotkeyCheck(keyString=key, alt=True)
                    result = 'Alt-' + key + '-Press'
            elif ctrl and alt:
                    mapping = pm.hotkeyCheck(keyString=key, ctl=True, alt=True)
                    result = 'Ctrl-Alt-' + key + '-Press'
    else:
            if not ctrl and not alt:
                    mapping = pm.hotkeyCheck(keyString=key, keyUp=True)
                    result = key + '-Release'
            elif ctrl and not alt:
                    mapping = pm.hotkeyCheck(keyString=key, ctl=True, keyUp=True)
                    result = 'Ctrl-' + key + '-Release'
            elif not ctrl and alt:
                    mapping = pm.hotkeyCheck(keyString=key, alt=True, keyUp=True)
                    result = 'Alt-' + key + '-Release'
            elif ctrl and alt:
                    mapping = pm.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'
    pm.scrollField( scrollField, edit=True, text=(result + ' is mapped to:\n\n' + mapping ) )

Previous topic

pymel.core.windows.hotkey

Next topic

pymel.core.windows.hudButton

Core

Core Modules

Other Modules

This Page