Caplin Trader 5.1.0

Class: KeybindingService

br/KeybindingService~KeybindingService()

A service that allows the binding of keyboard keys (shortcuts) to actions. The service is available under the alias br.keybinding-service and should be obtained through the service registry and not constructed. This service uses the Mousetrap library to handle keyboard bindings. Refer to its documentation to see what type of keys are supported.

Constructor

new KeybindingService()

See:

Methods

bindAction(actionId, keyShortcut)

Bind an action to a keyboard shortcut. This method will typically be used by the app code.

Parameters:
Name Type Description
actionId String

Action to bind.

keyShortcut String | Array

Refer to Mousetrap's documentation to see what keys are supported.

getAction(actionId) → {undefined|Object}

Get the information about a registered action.

Parameters:
Name Type Description
actionId String

Action to return.

Returns:
Type
undefined | Object

registerAction(actionId, actionCb)

Register an action that can then be bound to a shortcut key. This method will typically be used by a component that wishes to provide some functionality that will be invoked with a keyboard shortcut.

Parameters:
Name Type Description
actionId String

A unique string ID of the action. It is recommended that the ID is prefixed with the namespace of the component.

actionCb function

The function that will be invoked for this action.

Throws:

If trying to add an action that was already added.

Type
module:br/Errors#InvalidParametersError

removeAction(actionId)

Remove the action.

Parameters:
Name Type Description
actionId String
Throws:

If trying to remove a non existing action.

Type
module:br/Errors#InvalidParametersError

unbindAction(actionId)

Unbind an action from a keyboard shortcut. The action will not be removed. To remove it completely removeAction should be used.

Parameters:
Name Type Description
actionId String

Action to remove.