Keyboard Shortcuts Manager service

The Keyboard Shortcuts Manager service supports retrieving all keyboard shortcuts available in a workspace, or a specific subset of them, such as those assigned to the system, choices, or fields. It also provides information about the actions that these shortcuts trigger.

As a sample use case, you might want to implement custom keyboard shortcuts in layout, such as the document viewer. You could use this service to retrieve the information required to attach the appropriate shortcut to a specific field or choice, or for global use at the system level. Users could then navigate with the custom keyboard shortcuts through fields and choices, or trigger global actions with them.

The Relativity Services API supports the same functionality for this service as available through the REST API. For more information, see Keyboard Shortcuts Manager API.

This page contains the following information:

Client code sample

To use the Keyboard Shortcuts Manager service, send requests by making calls to the GetKeyboardShortcuts endpoint. See the following base URL for this service:

<host>/Relativity.Rest/API/Relativity.Services.KeyboardShortcuts.IKeyboardShortcutsModule/Keyboard%20Shortcuts%20Manager/

You can use the following .NET code as a sample client for retrieving keyboard shortcuts and related information. This code illustrates how to perform the following tasks:

  • Instantiate an HttpClient object for sending requests to the Keyboard Shortcuts Manager service.
  • Set the required headers for the request. For information on setting headers, see HTTP headers.
  • Initialize a variable with the Artifact ID of the workspace containing the keyboard shortcuts.
  • Set the JSON input required for the operation.
  • Set the url variable to the URL for retrieving the keyboard shortcuts. See Retrieve keyboard shortcuts.
  • Use the PostAsync() method to send a post request.
  • Return the results of the request and parse it.

    Note: The following code sample uses a JArray type for the objects returned in the response. However, you can use another list type.

public static async Task<JArray> GetKeyboardShortcuts()
{
JArray response = null;
   using (HttpClient client = new HttpClient())
   {
      client.DefaultRequestHeaders.Add("X-CSRF-Header", "-");
      client.DefaultRequestHeaders.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes("email@address:Password")));
      client.DefaultRequestHeaders.Add("X-Kepler-Version", "2.0");
      client.BaseAddress = new Uri("https://localhost/Relativity/");

      int workspaceId = 1015024;

      string inputJSON = $"{{\"WorkspaceID\": \"{workspaceId}\" }}";
      string url = "/Relativity.Rest/API/Relativity.Services.KeyboardShortcuts.IKeyboardShortcutsModule/KeyboardShortcutsManager/GetKeyboardShortcuts";
      HttpResponseMessage responseMessage = await client.PostAsync(url, new StringContent(inputJSON, Encoding.UTF8, "application/json"));
      string result = responseMessage.Content.ReadAsStringAsync().Result;
      response = JArray.Parse(result);
   }

   return response;
}

Retrieve keyboard shortcuts

To retrieve keyboard shortcuts available in a specific workspace, send a POST request to a URL with the following format:

<host>/Relativity.Rest/API/Relativity.Services.KeyboardShortcuts.IKeyboardShortcutsModule/Keyboard%20Shortcuts%20Manager/GetKeyboardShortcuts

The request contains the following fields:

  • WorkspaceID - the Artifact ID of the workspace that contains keyboard shortcuts.
  • RequestOptions - an optional request object containing one or more of the following fields:
    • IncludeSystemShortcuts - a Boolean value indicating whether to retrieve System shortcuts. The default value is true.
    • IncludeChoiceShortcuts - a Boolean value indicating whether to retrieve Choice shortcuts. The default value is true.
    • IncludeFieldShortcuts - a Boolean value indicating whether to retrieve Field shortcuts. The default value is true.

The following JSON samples illustrate options for the fields in the body of the request:

  • Workspace ID only - retrieves all the keyboard shortcuts in a workspace.
    {
        "WorkspaceID": 1017204
    }
  • Workspace ID and request options - retrieves a combination of system, choice, and field shortcuts based on the Boolean values assigned to the request fields. This sample code retrieves only keyboard shortcuts for choices.
    {
       "WorkspaceID":1017204,
       "RequestOptions":{
          "IncludeSystemShortcuts":false,
          "IncludeChoiceShortcuts":true,
          "IncludeFieldShortcuts":false
       }
    }

The response contains the following fields:

  • KeyboardShortcutID - a number used as the identifier for the keyboard shortcut.
  • Type - a string indicating the type of keyboard shortcut, such as system, choice, or field.
  • ArtifactID - a number representing the Artifact ID of a field or choice associated with the keyboard shortcut. This property is only returned when the type is "Choice" or "Field".
  • Action - a string indicating an action taken when a keyboard shortcut is triggered. The following types of action are available:
    • ToggleChoice - an action of this type is returned for Choice type keyboard shortcuts.
    • SelectField - an action of this type is returned for Field type keyboard shortcuts.
    • Other actions - include those for System type keyboard shortcuts.
  • KeysCombination - indicates whether additional keys are used as part of the shortcut. The following properties are available:
    • KeysCombination.Shift - a Boolean value indicating whether the Shift key is used in the key combination.
    • KeysCombination.Ctrl - a Boolean value indicating whether the Control key is used in the key combination.
    • KeysCombination.Alt - a Boolean value indicating whether the Alt key is used in the key combination.
    • KeysCombination.Key - a number indicating a key used in a specific keyboard shortcut combination.
[
    {
        "KeyboardShortcutID": 44,
        "Type": "System",
        "Action": "NavigateLastDocument",
        "KeysCombination": {
            "Shift": false,
            "Ctrl": false,
            "Alt": true,
            "Key": 67
        }
    },
    {
        "KeyboardShortcutID": 45,
        "Type": "Choice",
        "ArtifactID": 1038153,
        "Action": "ToggleChoice",
        "KeysCombination": {
            "Shift": false,
            "Ctrl": false,
            "Alt": true,
            "Key": 68
        }
    },
    {
        "KeyboardShortcutID": 46,
        "Type": "Field",
        "ArtifactID": 1035252,
        "Action": "SelectField",
        "KeysCombination": {
            "Shift": false,
            "Ctrl": false,
            "Alt": true,
            "Key": 69
        }
    }
]