A Keyboard Shortcut plugin module defines a keyboard shortcut within Bitbucket Data Center. A Bitbucket Data Center keyboard shortcut allows you to perform potentially any action in Bitbucket Data Center using one or more keyboard strokes – for example, navigating to a repository, viewing commits or browsing files.
The root element for the Keyboard Shortcut plugin module is keyboard-shortcut
. It allows the following attributes and child elements for
configuration:
Name | Required | Description | Default |
---|---|---|---|
key | Yes |
The identifier of the plugin module. This key must be unique within the plugin where it is defined.
Sometimes, in other contexts, you may need to uniquely identify a module.
Do this with the complete module key.
A module with key | N/A |
i18n-name | The localisation key for the human-readable name of the plugin module. | ||
name | The human-readable name of the plugin module. | The plugin key. | |
hidden |
When hidden='true' , the keyboard shortcut will not appear in the Keyboard
Shortcuts dialog box.
Despite not appearing in the dialog box, hidden keyboard shortcuts can still be accessed via the relevant keystrokes. | false |
Name | Required | Description |
---|---|---|
order | Yes |
A value that determines the order in which the shortcut appears on the
Keyboard Shortcuts dialog box, with respect to other `keyboard-shortcut`
plugin modules.
For each |
description | Yes | A human-readable description of this Keyboard Shortcut module. |
shortcut | Yes |
The sequence of keystrokes required to activate the keyboard shortcut. These
should be presented in the order that the keys are pressed on a keyboard. For
example, gb represents a keyboard shortcut activated by pressing 'g ' then
'b ' on the keyboard.
|
operation | Yes |
Defines the action to take when this shortcut is activated. The available
actions come from AJS.whenIType. The action is specified through the `type`
attribute of the operation element. The text content of this element is used
as a parameter to the AJS.whenIType function being called. Usually the
parameter is a jQuery selector
that specifies the target of the keyboard shortcut. Some actions take an optional second parameter. If you require specifying multiple parameters, you may use a strict JSON array as the operation element's text content, and this will be used as the `arguments` of the function. Available types are:
|
context |
The context defines which pages the shortcut will be active on.
|
These examples are taken from Bitbucket Data Center's pre-defined keyboard shortcuts:
1 2... <keyboard-shortcut key="shortcut-branch-selector" i18n-name="bitbucket.web.keyboardshortcut.branch.selector" name="Open Branch Selector"> <description key="bitbucket.web.keyboardshortcut.branch.selector.desc">Change branch/tag</description> <shortcut>b</shortcut> <operation type="click">#repository-layout-revision-selector</operation> <context>branch</context> </keyboard-shortcut> ... ... <keyboard-shortcut key="shortcut-commit-move-to-next-file" i18n-name="bitbucket.web.keyboardshortcut.commit.next.file" name="Commit - Open next file"> <description key="bitbucket.web.keyboardshortcut.commit.next.file.desc">Next file</description> <shortcut>j</shortcut> <operation type="evaluate">require('util/shortcuts').setup('requestMoveToNextHandler', this, 'j');</operation> <context>commit</context> </keyboard-shortcut> ...
Enabling a custom context requires handling of the "register-contexts.keyboardshortcuts" AJS event from JavaScript. In Bitbucket Data Center, this is also exposed as an event on 'util/events' if you prefer that API.
1 2AJS.bind("register-contexts.keyboardshortcuts", function(e, data) { data.shortcutRegistry.enableContext('my context'); });
or
1 2require('util/events').on('stash.widget.keyboard-shortcuts.register-contexts', function(registry) { registry.enableContext('my context'); });
Rate this page: