History

Add keyboard shortcut to open preferences

Thibaut Courouble committed 9 years ago

Commit 031b6241 parent 4984f003 files · +35 −17Browse files

Unified · Split

3 files
  1. assets/javascripts/app/shortcuts.coffee +3 −0
  2. assets/javascripts/templates/pages/help_tmpl.coffee +19 −13
  3. assets/javascripts/views/layout/document.coffee +13 −4
assets/javascripts/app/shortcuts.coffee+3−0
@@ -104,6 +104,9 @@ class app.Shortcuts · 103 unmodified lines
104 when 40104 when 40
105 @trigger 'pageBottom'105 @trigger 'pageBottom'
106 false106 false
107 when 188
108 @trigger 'preferences'
109 false
107 110
108 handleKeydownShiftEvent: (event, _force) ->111 handleKeydownShiftEvent: (event, _force) ->
109 return @handleKeydownEvent(event, true) if not _force and event.which in [37, 38, 39, 40] and @swapArrowKeysBehavior()112 return @handleKeydownEvent(event, true) if not _force and event.which in [37, 38, 39, 40] and @swapArrowKeysBehavior()
assets/javascripts/templates/pages/help_tmpl.coffee+19−13
@@ -45,7 +45,7 @@ app.templates.helpPage = """ · 44 unmodified lines
45 </dl>45 </dl>
46 46
47 <h2 class="_block-heading" id="shortcuts">Keyboard Shortcuts</h2>47 <h2 class="_block-heading" id="shortcuts">Keyboard Shortcuts</h2>
48 <h3 class="_shortcuts-title">Selection</h3>48 <h3 class="_shortcuts-title">Sidebar</h3>
49 <dl class="_shortcuts-dl">49 <dl class="_shortcuts-dl">
50 <dt class="_shortcuts-dt">50 <dt class="_shortcuts-dt">
51 <code class="_shortcut-code">&darr;</code>51 <code class="_shortcut-code">&darr;</code>
@@ -61,8 +61,11 @@ app.templates.helpPage = """ · 9 unmodified lines
61 <dt class="_shortcuts-dt">61 <dt class="_shortcuts-dt">
62 <code class="_shortcut-code">#{ctrlKey} + enter</code>62 <code class="_shortcut-code">#{ctrlKey} + enter</code>
63 <dd class="_shortcuts-dd">Open selection in a new tab63 <dd class="_shortcuts-dd">Open selection in a new tab
64 <dt class="_shortcuts-dt">
65 <code class="_shortcut-code">alt + r</code>
66 <dd class="_shortcuts-dd">Reveal current page in sidebar
64 </dl>67 </dl>
65 <h3 class="_shortcuts-title">Navigation</h3>68 <h3 class="_shortcuts-title">Browsing</h3>
66 <dl class="_shortcuts-dl">69 <dl class="_shortcuts-dl">
67 <dt class="_shortcuts-dt">70 <dt class="_shortcuts-dt">
68 <code class="_shortcut-code">#{navKey} + &larr;</code>71 <code class="_shortcut-code">#{navKey} + &larr;</code>
@@ -83,15 +86,24 @@ app.templates.helpPage = """ · 14 unmodified lines
83 <code class="_shortcut-code">#{ctrlKey} + &uarr;</code>86 <code class="_shortcut-code">#{ctrlKey} + &uarr;</code>
84 <code class="_shortcut-code">#{ctrlKey} + &darr;</code>87 <code class="_shortcut-code">#{ctrlKey} + &darr;</code>
85 <dd class="_shortcuts-dd">Scroll to the top/bottom88 <dd class="_shortcuts-dd">Scroll to the top/bottom
86 </dl>
87 <h3 class="_shortcuts-title">Misc</h3>
88 <dl class="_shortcuts-dl">
89 <dt class="_shortcuts-dt">89 <dt class="_shortcuts-dt">
90 <code class="_shortcut-code">alt + f</code>90 <code class="_shortcut-code">alt + f</code>
91 <dd class="_shortcuts-dd">Focus first link in the content area<br>(press tab to focus the other links)91 <dd class="_shortcuts-dd">Focus first link in the content area<br>(press tab to focus the other links)
92 </dl>
93 <h3 class="_shortcuts-title">App</h3>
94 <dl class="_shortcuts-dl">
92 <dt class="_shortcuts-dt">95 <dt class="_shortcuts-dt">
93 <code class="_shortcut-code">alt + r</code>96 <code class="_shortcut-code">ctrl + ,</code>
94 <dd class="_shortcuts-dd">Reveal current page in sidebar97 <dd class="_shortcuts-dd">Open preferences
98 <dt class="_shortcuts-dt">
99 <code class="_shortcut-code">escape</code>
100 <dd class="_shortcuts-dd">Reset UI
101 <dt class="_shortcuts-dt">
102 <code class="_shortcut-code">?</code>
103 <dd class="_shortcuts-dd">Show this page
104 </dl>
105 <h3 class="_shortcuts-title">Miscellaneous</h3>
106 <dl class="_shortcuts-dl">
95 <dt class="_shortcuts-dt">107 <dt class="_shortcuts-dt">
96 <code class="_shortcut-code">alt + o</code>108 <code class="_shortcut-code">alt + o</code>
97 <dd class="_shortcuts-dd">Open original page109 <dd class="_shortcuts-dd">Open original page
@@ -101,12 +113,6 @@ app.templates.helpPage = """ · 3 unmodified lines
101 <dt class="_shortcuts-dt">113 <dt class="_shortcuts-dt">
102 <code class="_shortcut-code">alt + s</code>114 <code class="_shortcut-code">alt + s</code>
103 <dd class="_shortcuts-dd">Search on Stack Overflow115 <dd class="_shortcuts-dd">Search on Stack Overflow
104 <dt class="_shortcuts-dt">
105 <code class="_shortcut-code">escape</code>
106 <dd class="_shortcuts-dd">Reset<br>(press twice in single doc mode)
107 <dt class="_shortcuts-dt">
108 <code class="_shortcut-code">?</code>
109 <dd class="_shortcuts-dd">Show this page
110 </dl>116 </dl>
111 <p class="_note">117 <p class="_note">
112 <strong>Tip:</strong> If the cursor is no longer in the search field, press <code class="_label">/</code> or118 <strong>Tip:</strong> If the cursor is no longer in the search field, press <code class="_label">/</code> or
assets/javascripts/views/layout/document.coffee+13−4
@@ -5,10 +5,11 @@ class app.views.Document extends app.View · 4 unmodified lines
5 visibilitychange: 'onVisibilityChange'5 visibilitychange: 'onVisibilityChange'
6 6
7 @shortcuts:7 @shortcuts:
8 help: 'onHelp'8 help: 'onHelp'
9 escape: 'onEscape'9 preferences: 'onPreferences'
10 superLeft: 'onBack'10 escape: 'onEscape'
11 superRight: 'onForward'11 superLeft: 'onBack'
12 superRight: 'onForward'
12 13
13 @routes:14 @routes:
14 after: 'afterRoute'15 after: 'afterRoute'
@@ -46,6 +47,11 @@ class app.views.Document extends app.View · 31 unmodified lines
46 47
47 onHelp: ->48 onHelp: ->
48 app.router.show '/help#shortcuts'49 app.router.show '/help#shortcuts'
50 return
51
52 onPreferences: ->
53 app.router.show '/settings'
54 return
49 55
50 onEscape: ->56 onEscape: ->
51 path = if !app.isSingleDoc() or location.pathname is app.doc.fullPath()57 path = if !app.isSingleDoc() or location.pathname is app.doc.fullPath()
@@ -54,12 +60,15 @@ class app.views.Document extends app.View · 2 unmodified lines
54 app.doc.fullPath()60 app.doc.fullPath()
55 61
56 app.router.show(path)62 app.router.show(path)
63 return
57 64
58 onBack: ->65 onBack: ->
59 history.back()66 history.back()
67 return
60 68
61 onForward: ->69 onForward: ->
62 history.forward()70 history.forward()
71 return
63 72
64 onClick: (event) ->73 onClick: (event) ->
65 return unless event.target.hasAttribute('data-behavior')74 return unless event.target.hasAttribute('data-behavior')

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t