Custom Hotkeys

How do I create custom hotkeys in RV?

1 Like

Hi there!

Thank you for reaching out via community :slight_smile:

Unfortunately itā€™s not the most artist-friendly workflow :frowning:

You can do it in three ways:

  1. Add an .rvrc.mu or .rvrc.py file in your home directory. (more on this below)
  2. Redefine key bindings in a custom Python package. This is very flexible and you can bundle key definitions with multiple RV versions at the same time.
  3. Change rvui.mu . This is a file that is included in every version of RV that defines the menus and their key bindings. This is easier but itā€™s also very fragile. Youā€™ll have to redefine hotkeys every time that you update your version of RV and have to remember that you have rvui.mu modified.

Package building can get complicated, so if you want a quick solution you can try this. If users want to add their own keybindings, they can be added to the userā€™s .rvrc.mu or .rvrc.py files in their home directories.

Check out this section on the user manual RV User Manual - User Interface Key and Mouse Bindings.

If you check the default implementation of rvrc.mu (You can find it under $RV_HOME/Mu/rvrc.mu ), it looks like this:

require rvui;

documentation:
"Called when a session is first created";

\: initialize (object;)
{
    //
    //  To override default bindings just set them after you call this,
    //  otherwise, you need to provide all of the bindings if you
    //  replace it.
    //

    rvui.defineDefaultBindings();

    //
    //  You can add to rvui.mainMenu before calling this
    //

    defineModeMenu("default", rvui.buildMainMenu());

    //
    //  Make a new State object. Any object can be returned here
    //  (tuple, etc). In this case we're going to provide the default
    //  State object.
    //

    return rvui.newStateObject();
}

I wonā€™t paste the rvui.mu file as it is too big, but if you look at the defineDefaultBindings method, youā€™ll find a bunch of bindings that look like this:

    bind("key-down--.", incN(1), "Set Frame Increment to 1 (forward)");
    bind("key-down--1", pixelRelativeScale(1.0), "Scale 1:1");
    bind("key-down--2", pixelRelativeScale(2.0), "Scale 2:1");
    bind("key-down--3", pixelRelativeScale(3.0), "Scale 3:1");
    bind("key-down--4", pixelRelativeScale(4.0), "Scale 4:1");
    bind("key-down--5", pixelRelativeScale(5.0), "Scale 5:1");
    bind("key-down--6", pixelRelativeScale(6.0), "Scale 6:1");
    bind("key-down--7", pixelRelativeScale(7.0), "Scale 7:1");
    bind("key-down--8", pixelRelativeScale(8.0), "Scale 8:1");
    bind("key-down--A", toggleRealtime, "Toggle Real-Time Playback");
    bind("key-down--C", toggleCacheModeFunc(CacheGreedy), "Toggle Region Caching");
    bind("key-down--D", toggleDisplayLUT, "Toggle Display LUT");
    bind("key-down--F", enterFPS, "Enter FPS Value From Keyboard");

You donā€™t need to know what it does, all you really need to change the numbers/letters to the key-down-- bindings. This way each user can define key bindings in their copy of the rvrc.mu file after copying it to their home directory as ~/.rvrc.mu .

I have attached a python example as well! bind_example_rvrc.py (305 Bytes)

If you decide to go a package way, I can show you how to do that as well.

Thanks,
Alexa

2 Likes

whatā€™s the easiest way to disable a default hotkey like ā€œqā€?
I created a ~/rvrc.py file and added the below lines but it has no effect:

from rv import rvui, commands, extra_commands

def initialize():
    rvui.defineDefaultBindings()
    return rvui.newStateObject()

def setup():
    def disable_Q(event):
        pass

    commands.bind("default", "global", "q", disable_Q, "Null")
    return
1 Like

DOH, got it. had to be

commands.bind("default", "global", "key-down--q", disable_Q, "Null")
1 Like

@frank Hereā€™s a package version of the same thing in case you want it a bit easier to bundle up.

Q_Disable-1.0.rvpkg (758 Bytes)

2 Likes

Ah nice, thanks Michael!

1 Like

The answer is easy, Kessler probably has a package for that :wink:

2 Likes

thanks for the documentation on this. Iā€™m very new to configuring RV but wanted to set up a few defaults and hotkeys.

How would I go about finding out what the command is for setting hotkeys for items not listed in the example. For instance I am comfortable looking for a line such as this

bind(ā€œkey-downā€“5ā€, pixelRelativeScale(5.0), ā€œScale 5:1ā€);

and replacing the sections where needed. In nuke for instance I can easily mouse over to find what a knob is to set but donā€™t know how to do that in RV

In my case I would like to set a hotkey for switching to ā€œdefault stackā€ and another set of hotkeys to switch between frames and movie files.

1 Like

Hi @keggers,

Almost everything state-changing is represented in the rv session file with exception of display settings. One method I use readily is to save an RV session prior to changing a setting, then a second after changing the setting and then using diff (often with -C10 to give me context, or use meld or your fav. visual diff program) to see what changed.

1 Like

Thanks for the help Michael. Thatā€™s just an insane and un-friendly way to have to configure hotkeys for anyone! If thatā€™s the only way iā€™ll run with it, seems insane.

Itā€™s given me some limited clues, thank you. Iā€™ll keep investigating.

Kyle.

1 Like

Thank you for that feedback, Kyle! Itā€™s certainly not an intuitive process for an end user to configure. Iā€™m relaying your frustration to our product team.

Thanks,
Alexa

1 Like

Thanks Alexaz!

2 Likes

Hello, how would I go about adding a shortcut to cycle the stack backwards? Iā€™m adapting the code from above but Iā€™m getting an error

"ERROR: ā€˜moduleā€™ object has no attribute ā€˜cycleStackBackwardā€™

below is the code that Iā€™m using in rvrc.py.

from rv import rvui, commands, extra_commands

def initialize():
    rvui.defineDefaultBindings()
    return rvui.newStateObject()

def setup():
    def cycle(Event):
        rvui.cycleStackBackward()

    commands.bind("default", "global", "key-down--q", cycle, "Play")
    return

rvui isnā€™t a ā€˜built-inā€™ module, so the functions arenā€™t automatically bound to Python, you probably want to do something like:

from PyMu import MuSymbol
cycle_backward = MuSymbol('rvui.cycleStackBackward')

then in your cycle() method:

cycle_backward(event)

(If you look at the rvui.mu code, youā€™ll see that needs an event, alternatiely you can bind directly to it, or use smartCycleInputs with a bool.

1 Like

Hello,

How would I make a shortcut to show and hide annotations?

Thanks

Hi, i know nothing about scripting python but can anyone help meā€¦ i want to change keybinding for ā€œStep Forward 1 Frameā€ and ā€œMove Back One Frameā€. iā€™ve tried to write but nothing happen T_T


from rv import rvui, commands, extra_commands

def initialize():
rv.rvui.defineDefaultBindings()
return rv.rvui.newStateObject();

def setup():
def eventMoveBackOneFrame(event):
extra_commands.MoveBackOneFrame()

commands.bind("default", "key-down--alt--z", eventMoveBackOneFrame, "MoveBackOneFrame")
return