Create a ticket

Q100118: Setting custom keyboard shortcuts in Nuke 9 and 10


Due to changes with how Nuke handles shortcuts, custom hotkeys set up for Nuke 8.0 earlier may not work in Nuke 9.0 or above.
This article explains what has changed and how you can get your hotkeys to work in Nuke 9.0 and above.


Nuke 9.0 and 10 use a new shortcut system which has a context for when the shortcut is active.  The default context is to apply the shortcut to the whole Nuke window.
This can lead to problems if you set a custom hotkey to create a node in the nodegraph that uses a key that has an existing shortcut elsewhere - e.g. the W, H or R, G, B and A keys in the viewer.  If you don't include a context then when the mouse is over the viewer there will be 2 shortcuts using the same letter, which means that neither will run and Nuke will print a "Ambiguous short error" message in the terminal or command prompt.
To avoid this problem, Nuke's menu.addCommand() function has a new argument in Nuke 9.0 and 10.0 called "shortcutContext" to say where the shortcut should run.  It has 3 possible values 0=Window, 1=Application, 2=DAG/nodegraph. So an example command to create a custom write gizmo in Nuke 9.0 or 10.0 would look something like
toolbar.addCommand('MenuLocation', 'nuke.createNode("MyWriteGizmo")', 'w', shortcutContext=2)
Please note that this argument won't be recognised by Nuke 8.0 or earlier so if you add the line to your file it will prevent Nuke 8.0 or earlier from launching. To work around this you can use the following in your
if nuke.env['NukeVersionMajor'] < 9 :
toolbar.addCommand('MenuLocation', 'nuke.createNode("MyWriteGizmo")', 'w')
toolbar.addCommand('MenuLocation', 'nuke.createNode("MyWriteGizmo")', 'w', shortcutContext=2)


More information about assigning hotkeys and customising Nuke's menus is available in the Nuke Python Developers Guide chapter on Customising the UI.

Keywords: Nuke, shortcut, hotkey, customisation, customization
Was this article helpful?

We're sorry to hear that!

Please tell us why.
4 out of 12 found this helpful