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