PageRenderTime 51ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/content/server/jira/platform/keyboard-shortcut.md

https://bitbucket.org/mrzymski/jira-server-docs
Markdown | 217 lines | 193 code | 24 blank | 0 comment | 0 complexity | db4fab76b92357cbdf7106b3a9ef0af0 MD5 | raw file
  1. ---
  2. aliases:
  3. - /server/jira/platform/keyboard-shortcut-plugin-module-4227166.html
  4. - /server/jira/platform/keyboard-shortcut-plugin-module-4227166.md
  5. category: reference
  6. confluence_id: 4227166
  7. dac_edit_link: https://developer.atlassian.com/pages/editpage.action?cjm=wozere&pageId=4227166
  8. dac_view_link: https://developer.atlassian.com/pages/viewpage.action?cjm=wozere&pageId=4227166
  9. date: '2017-12-08'
  10. legacy_title: Keyboard Shortcut Plugin Module
  11. platform: server
  12. product: jira
  13. subcategory: modules
  14. title: Keyboard shortcut
  15. ---
  16. # Keyboard shortcut
  17. <table>
  18. <colgroup>
  19. <col style="width: 20%" />
  20. <col style="width: 80%" />
  21. </colgroup>
  22. <tbody>
  23. <tr class="odd">
  24. <td><p>Available:</p></td>
  25. <td><p>JIRA 4.1 and later</p></td>
  26. </tr>
  27. <tr class="even">
  28. <td><p>Changed:</p></td>
  29. <td><p>In JIRA 4.2 and later, the <code>keyboard-shortcut</code> element accepts an optional child element (<code>hidden</code>), which prevents the keyboard shortcut from appearing on the keyboard shortcuts dialog box. Existing keyboard shortcuts can also be overridden.</p></td>
  30. </tr>
  31. </tbody>
  32. </table>
  33. ## Purpose of this Module Type
  34. A keyboard shortcut plugin module defines a keyboard shortcut within JIRA. A JIRA keyboard shortcut allows you to perform potentially any action in JIRA using one or more keyboard strokes - for example, going to the Dashboard, browsing a project, moving your cursor to a field on a JIRA form, or creating, editing or commenting on an issue.
  35. ## Configuration
  36. The root element for the keyboard shortcut plugin module is `keyboard-shortcut`. It allows the following attributes and child elements for configuration:
  37. #### Attributes
  38. <table>
  39. <colgroup>
  40. <col style="width: 20%" />
  41. <col style="width: 80%" />
  42. </colgroup>
  43. <thead>
  44. <tr class="header">
  45. <th><p>Name</p></th>
  46. <th><p>Description</p></th>
  47. </tr>
  48. </thead>
  49. <tbody>
  50. <tr class="odd">
  51. <td><p>key</p></td>
  52. <td><p>The unique identifier of the plugin module. You refer to this key to use the resource from other contexts in your plugin, such as from the plugin Java code or JavaScript resources.</p>
  53. <p> </p>
  54. <pre><code>&lt;component-import
  55. key=&quot;appProps&quot;
  56. interface=&quot;com.atlassian.sal.api.ApplicationProperties&quot;/&gt;</code></pre>
  57. <p> </p>
  58. <p>In the example, <code>appProps</code> is the key for this particular module declaration, for <code>component-import</code>, in this case.</p>
  59. <p><strong>Required: yes</strong></p>
  60. <p><strong>Default: N/A</strong></p></td>
  61. </tr>
  62. <tr class="even">
  63. <td><p>i18n-name-key</p></td>
  64. <td><p>The localisation key for the human-readable name of the plugin module.</p>
  65. <p><strong>Required: -</strong></p>
  66. <p><strong><strong>Default: -</strong></strong></p></td>
  67. </tr>
  68. <tr class="odd">
  69. <td><p>name</p></td>
  70. <td>The human-readable name of the plugin module.
  71. <p><strong>Required: -</strong></p>
  72. <p><strong>Default:</strong> The plugin key.</p></td>
  73. </tr>
  74. <tr class="even">
  75. <td><p>hidden</p></td>
  76. <td><p>When <code>hidden='true'</code>, the keyboard shortcut will not appear in the <a href="http://confluence.atlassian.com/display/JIRA/Using+Keyboard+Shortcuts#UsingKeyboardShortcuts-AccessingtheKeyboardShortcutsDialogBox" class="external-link">Keyboard Shortcuts dialog box</a>.</p>
  77. {{% note %}}
  78. <div class="confluence-information-macro confluence-information-macro-note">
  79. <div class="confluence-information-macro-body">
  80. <p>Despite not appearing in the dialog box, hidden keyboard shortcuts can still be accessed via they keystrokes.</p>
  81. </div>
  82. </div>
  83. {{% /note %}}{{% note %}}
  84. <div class="confluence-information-macro confluence-information-macro-note">
  85. <div class="confluence-information-macro-body">
  86. <p>This attribute is only available in JIRA 4.2 and later.</p>
  87. </div>
  88. </div>
  89. {{% /note %}}
  90. <p><strong>Required: -</strong></p>
  91. <p><strong>Default:</strong> false</p>
  92. <p> </p></td>
  93. </tr>
  94. </tbody>
  95. </table>
  96. #### Elements
  97. <table>
  98. <colgroup>
  99. <col style="width: 20%" />
  100. <col style="width: 80%" />
  101. </colgroup>
  102. <thead>
  103. <tr class="header">
  104. <th><p>Name</p></th>
  105. <th><p>Description</p></th>
  106. </tr>
  107. </thead>
  108. <tbody>
  109. <tr class="odd">
  110. <td><p>order</p></td>
  111. <td><p>A value that determines the order in which the shortcut appears on the <a href="http://confluence.atlassian.com/display/JIRA/Using+Keyboard+Shortcuts#UsingKeyboardShortcuts-AccessingtheKeyboardShortcutsDialogBox" class="external-link">Keyboard Shortcuts dialog box</a> (with respect to other <code>keyboard-shortcut</code> plugin modules). This element is also used to override existing shortcuts displayed on the Keyboard Shortcuts dialog box (see <a href="#overriding-existing-keyboard-shortcuts">Overriding Existing Keyboard Shortcuts</a>).</p>
  112. {{% note %}}
  113. <div class="confluence-information-macro confluence-information-macro-note">
  114. <div class="confluence-information-macro-body">
  115. <p>For each <code>keyboard-shortcut</code> plugin module, we recommend using gaps in <code>order</code> values (for example, <code>10</code>, <code>20</code>, <code>30</code>, etc.) rather than consecutive values. This will allow you to 'insert' new keyboard shortcuts more easily into the keyboard shortcuts dialog box.</p>
  116. </div>
  117. </div>
  118. {{% /note %}}
  119. <p><strong>Required: yes</strong></p></td>
  120. </tr>
  121. <tr class="even">
  122. <td><p>description</p></td>
  123. <td><p>A human-readable description of this keyboard shortcut module. May be specified as the value of this element for plain text or with the <code>key</code> attribute to use the value of a key from the i18n system.</p>
  124. <p><strong>Required: yes</strong></p></td>
  125. </tr>
  126. <tr class="odd">
  127. <td><p>shortcut</p></td>
  128. <td><p>The sequence of keystrokes required to activate the keyboard shortcut's operation. These should be presented in the order that the keys are pressed on a keyboard. For example, <code>gb</code> represents a keyboard shortcut whose operation is activated after pressing '<code>g</code>', followed by '<code>b</code>' on the keyboard.</p>
  129. <p><strong>Required: yes</strong></p></td>
  130. </tr>
  131. <tr class="even">
  132. <td><p>operation</p></td>
  133. <td><p>A <a href="http://api.jquery.com/category/selectors/" class="external-link">jQuery selector</a> that specifies the target of the keyboard shortcut. The target is typically a component of the current page that performs an action. The <code>operation</code> element is accompanied by a <code>type</code> attribute that specifies the type of keyboard shortcut operation. For more information on the available types, please refer to the <a href="http://docs.atlassian.com/jira/latest/com/atlassian/jira/plugin/keyboardshortcut/KeyboardShortcutManager.Operation.html#enum_constant_detail" class="external-link">JIRA API documentation</a>.</p>
  134. <p><strong>Required: yes</strong></p></td>
  135. </tr>
  136. <tr class="odd">
  137. <td><p>context</p></td>
  138. <td><p>The section of the Keyboard Shortcuts dialog box on which the shortcut appears and defines where the keyboard shortcut can be used in JIRA. If this element contains:</p>
  139. <ul>
  140. <li><code>global</code> (or is omitted) -- the keyboard shortcut appears in the 'Global Shortcuts' section of this dialog box.</li>
  141. <li><code>issueaction</code> -- the keyboard shortcut appears in the 'Issue Actions' section of the dialog box.</li>
  142. <li><code>issuenavigation</code> -- the keyboard shortcut appears in the 'Navigating Issues' section of the dialog box.</li>
  143. </ul>
  144. <p><strong>Required: -</strong></p></td>
  145. </tr>
  146. </tbody>
  147. </table>
  148. ### Overriding Existing Keyboard Shortcuts
  149. {{% note %}}
  150. This feature is only available in JIRA 4.2 and later.
  151. {{% /note %}}
  152. You can override an existing keyboard shortcut defined either within JIRA itself or in another plugin.
  153. To do this create a `keyboard-shortcut` plugin module with exactly the same `shortcut` element's keystroke sequence as that of the keyboard shortcut you want to override. Then, ensure that an `order` element is added, whose value *is greater than* that defined in the keyboard shortcut being overridden.
  154. While the `order` element may affect the position of your overriding keyboard shortcut on the Keyboard Shortcuts dialog box, it will also prevent the overridden keyboard shortcut from:
  155. - being accessed via the keyboard and
  156. - appearing in the dialog box, on the proviso that you are overriding the keyboard shortcut within the same 'context' (i.e. with the same `context` element above).
  157. ### Internationalisation
  158. It is possible to include an i18n resource in your `atlassian-plugin.xml` to translate keyboard shortcut descriptions (via their '`key`' attributes) into multiple languages. For examples code on including i18n resources in your `atlassian-plugin.xml` file, please refer to [Downloadable Plugin Resources](/server/jira/platform/downloadable-add-on-resources).
  159. ## Examples
  160. These examples are taken from JIRA's pre-defined keyboard shortcuts for going to the Dashboard, commenting on an issue and moving to the next action item on an issue view.
  161. ``` javascript
  162. ...
  163. <keyboard-shortcut key="goto.dashboard" i18n-name="admin.keyboard.shortcut.goto.dashboard.name"
  164. name="Goto Dashboard">
  165. <order>10</order>
  166. <description key="admin.keyboard.shortcut.goto.dashboard.desc">Go to Dashboard</description>
  167. <shortcut>gd</shortcut>
  168. <operation type="followLink">#home_link</operation>
  169. </keyboard-shortcut>
  170. ...
  171. ...
  172. <keyboard-shortcut key="comment.issue" i18n-name="admin.keyboard.shortcut.commentissue.name"
  173. name="Comment Issue"
  174. state='enabled'>
  175. <order>80</order>
  176. <description key="admin.keyboard.shortcut.commentissue.desc">Scrolls to comment input and focuses it</description>
  177. <shortcut>m</shortcut>
  178. <operation type="click">#comment-issue</operation>
  179. <context>issueaction</context>
  180. </keyboard-shortcut>
  181. ...
  182. ...
  183. <keyboard-shortcut key="move.to.next.action.item" i18n-name="admin.keyboard.shortcut.movetonextactionitem.name"
  184. name="Move to next action item"
  185. state='enabled'>
  186. <order>110</order>
  187. <description key="admin.keyboard.shortcut.movetonextactionitem.desc">Moves to the next action item on view issue page</description>
  188. <shortcut>n</shortcut>
  189. <operation type="moveToNextItem">.issue-data-block:visible</operation>
  190. <context>issueaction</context>
  191. </keyboard-shortcut>
  192. ...
  193. ```