Reassign keyboard shortcuts in Nuke6.3v8 -- now it's simple!

Written by Tim BOWMAN on .

Now that Nuke 6.3v8 is out, the Foundry has given us a simple way to reassign keyboard shortcuts for items that are already in menus. This used to be rather complicated, but now it's easy. Here's how.

As an example we'll reassign the Posterize node to the control-p shortcut. In the "Nodes" panel, the vertical one with all the icons, Posterize lives in the "Color" submenu.

# We start by finding the "Nodes" menu.
nodes_menu = nuke.menu('Nodes')

# Here we verify that we got it correctly.
print nodes_menu.name()

# From there, we find the "Color" menu.
color = nodes_menu.findItem('Color')
# Also verifying that we got it.
print color.name()

# Now we grab the Posterize item.
posterize = color.findItem('Posterize')
# Verifying that we got it correctly and seeing if it already has a shortcut.
print posterize.name(), 'has this shortcut assigned:', posterize.shortcut()

You probably won't see any shortcut at all. Posterize doesn't have anything assigned by default. So let's set one.

posterize.setShortcut('Ctrl+P')

Now let's try printing the shortcut again.

print posterize.name(), 'has this shortcut assigned:', posterize.shortcut()

You should see in the script editor that Posterize has now been set to control-p. Try it and you'll drop a Posterize in the node graph. You can also see the shortcut when you find "Posterize" in the "Color" submenu from the "Nodes" panel.

You can use this technique to assign shortcuts to anything you find in Nuke's menus. The tricky bit is to know where to start. Earlier, we used the "Nodes" panel, but you can also change shortcuts in the menu bar along the top of the Nuke window by replacing "Nodes" with "Nuke" in the nuke.menu command. These two are the most common menus, but there are a few more. You can find out all about them by using the "help" command in the script editor.

help(nuke.menu)

Comments   

 
+1 # randy vellacott 2012-11-12 18:22
Can you set a shortcut for a selection within a node. i.e stencil within merge.
 
 
0 # Tim BOWMAN 2012-11-12 19:47
HI Randy! For that kind of thing you'd be better off writing a short function that drops the node in the in the mode you want and calling that function with a keyboard shortcut. It'd be a good tutorial, I might write it up if I have some time.
 
 
0 # randy vellacott 2012-11-12 20:40
Thanks Tim, as they say in the classics I was only asking for a friend, but sounds like something I would definitely use. Don't know why mask and stencil aren't in the keyboard shortcuts or why they made an in and out node and not the more useful mask and stencil ... go figure.
 
 
+2 # Philippe HUBERDEAU 2012-12-05 05:11
For Stencil shortcut and things like that i use the Toolsets menu. Didn't know about the "setShortcut" function but that was my workaround...

ms = nuke.menu("Nodes").menu("ToolSets").addMenu("shortcuts")
ms.addCommand("Multiply", "nuke.createNod e("Merge2", "operation multiply")","Shift+m")
ms.addCommand("Stencil", "nuke.createNod e("Merge2", "operation stencil")","Ctrl+m")
ms.addCommand("Copy", "nuke.createNod e("Merge2", "operation copy")","Ctrl+shift+m")

and voilà ! Hope that help
Cheers
philhub
 
 
0 # Thomas Vu 2016-01-19 14:56
i really want to change pan shorcut key from "Alt" to "Space" and zoom from scroll or mid click from wacom to Ctrl + Space + draft left mouse

any idea. i need some help
 

You have no rights to post comments

We have 3345 guests and 117 members online