Keyboard Commands

Information about how to create and modify key bindings

Keybindings

OpenSpace provides the ability to bind one or more commands to a single key press. This is a useful feature that provides quick access to things that may be specific to a scene, or to the type of information that is being focused on in a session. It is an especially useful tool for presentations, because it can significantly reduce the workload on the presenter.

Default Keybindings

OpenSpace contains the file data/assets/util/default_keybindings.asset which is referenced in many of the .scene files using the command  asset.require('util/default_keybindings'). This file provides a way for many different scenes to share keybindings.

Assigning Keybindings Specific to a Scene

Keybindings can also be assigned only to a specific scene, by adding a Keybindings entry in the corresponding .scene file. The following is an example from default.scene:

    {
        Key = "b",
        Command = sceneHelper.property.invert('MilkyWay.renderable.Enabled') ..
                  sceneHelper.property.invert('Stars.renderable.Enabled'),
        Documentation = "Toggle background (Stars and Milkyway).",
        Local = false
    },

Pressing the b key will invoke the two commands specified. Normally a single command is bound but multiple commands can be combined using .. in the Command entry. A description of the binding is provided in the Documentation entry, which will be added to the auto-generated documentation (KeyboardMapping.html). Finally, a Local = false entry means that the command(s) will run on all connected OpenSpace nodes in a parallel session (an entry of true limits the command only to the master node).

As an example, the OSIRIS-REx mission uses keybindings to easily access important functionality for that scene. The osirisrex.scene file contains keybindings that invoke a jump to the date and time of a particular event in the mission, and also focus the camera on important scene elements such as the probe or the asteroid Bennu.

Changing Keybindings

The command openspace.rebindKey(oldKey, newKey) can be used to re-assign all commands currently bound to oldKey and bind them to newKey. It is not necessary to provide the list of commands that apply to the binding.