Skip to content
This repository was archived by the owner on Nov 8, 2017. It is now read-only.

Commit 53e02a2

Browse files
committed
Merge pull request #36 from Fishrock123/windows-control-key
Map the ctrl key as cmd if the user is on windows.
2 parents fefb5e2 + 07d1303 commit 53e02a2

File tree

3 files changed

+44
-33
lines changed

3 files changed

+44
-33
lines changed

build/index.html

+9-9
Original file line numberDiff line numberDiff line change
@@ -256,17 +256,17 @@
256256

257257
<div class="menu-item red" id="save-item">
258258
<span buttontext>Save</span>
259-
<div class="shortcut"><span class="modifier"></span>S</div>
259+
<div class="shortcut"><span class="modifier"></span>S</div>
260260
</div>
261261

262262
<div class="menu-item red shortcut" id="save-as-item">Save as...
263-
<div class="shortcut"><span class="modifier"></span>S</div>
263+
<div class="shortcut"><span class="modifier"></span>S</div>
264264
</div>
265265

266266
<div class="separator"><div class="separator-line"></div></div>
267267

268268
<div class="menu-item red shortcut" id="open-item">Open...
269-
<div class="shortcut"><span class="modifier"></span>O</div>
269+
<div class="shortcut"><span class="modifier"></span>O</div>
270270
</div>
271271

272272
<div class="menu-item red" id="open-from-hd-item">Open from hard drive...
@@ -304,11 +304,11 @@
304304
<div class="menu-dropdown with-shortcuts" id="edit-menu-dropdown">
305305

306306
<div class="menu-item yellow shortcut" id="undo-item">Undo
307-
<div class="shortcut"><span class="modifier"></span>Z</div>
307+
<div class="shortcut"><span class="modifier"></span>Z</div>
308308
</div>
309309

310310
<div class="menu-item yellow shortcut" id="redo-item">Redo
311-
<div class="shortcut"><span class="modifier"></span>Z</div>
311+
<div class="shortcut"><span class="modifier"></span>Z</div>
312312
</div>
313313

314314
<div class="menu-item yellow shortcut" id="visual-history">Visual History
@@ -318,23 +318,23 @@
318318
<div class="separator"><div class="separator-line"></div></div>
319319

320320
<div class="menu-item yellow shortcut" id="cut-item">Cut
321-
<div class="shortcut"><span class="modifier"></span>X</div>
321+
<div class="shortcut"><span class="modifier"></span>X</div>
322322
</div>
323323

324324
<div class="menu-item yellow shortcut" id="copy-item">Copy
325-
<div class="shortcut"><span class="modifier"></span>C</div>
325+
<div class="shortcut"><span class="modifier"></span>C</div>
326326
</div>
327327

328328
<div class="menu-item yellow shortcut" id="paste-item">Paste
329-
<div class="shortcut"><span class="modifier"></span>V</div>
329+
<div class="shortcut"><span class="modifier"></span>V</div>
330330
</div>
331331

332332
<div class="menu-item yellow shortcut" id="delete-item">Delete
333333
<div class="shortcut"><span class="modifier"></span></div>
334334
</div>
335335

336336
<div class="menu-item yellow shortcut bottom" id="select-all-item">Select all
337-
<div class="shortcut"><span class="modifier"></span>A</div>
337+
<div class="shortcut"><span class="modifier"></span>A</div>
338338
</div>
339339

340340
</div>

src/coffee/ui/hotkeys.coffee

+19-24
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ ui.hotkeys =
164164

165165
lastEvent: {}
166166

167+
modifierCodes:
168+
8: 'backspace'
169+
16: 'shift'
170+
17: 'ctrl'
171+
18: 'alt'
172+
91: 'cmd'
173+
92: 'cmd'
174+
224: 'cmd'
167175

168176
###
169177
Strategy:
@@ -178,6 +186,11 @@ ui.hotkeys =
178186
###
179187

180188
setup: ->
189+
# Map the ctrl key as cmd if the user is on windows.
190+
if ~navigator.appVersion.indexOf("Win")
191+
@modifierCodes[17] = 'cmd'
192+
dom.body?.setAttribute 'os', 'windows'
193+
181194
@use "app"
182195

183196
ui.window.on 'focus', =>
@@ -205,17 +218,10 @@ ui.hotkeys =
205218
# Save this event for
206219
@lastEvent = e
207220

208-
if not e.metaKey
209-
@cmdDown = false
210-
@registerModifierUp "cmd"
211-
else
212-
@registerModifier "cmd"
213-
214221
# Cmd has been pushed
215222
if keystroke is 'cmd'
216-
if not @cmdDown
217-
@cmdDown = true # Custom tracking for cmd
218-
@registerModifier "cmd"
223+
@cmdDown = true # Custom tracking for cmd
224+
@registerModifier "cmd"
219225
return
220226

221227
else if keystroke in ['shift', 'alt', 'ctrl']
@@ -323,8 +329,7 @@ ui.hotkeys =
323329
@using.up?.always?.call(@using.context, @lastEvent)
324330

325331
if keystroke is 'cmd' # CMD has been released!
326-
@modifiersDown = @modifiersDown.remove 'cmd'
327-
ui.uistate.get('tool').deactivateModifier 'cmd'
332+
@registerModifierUp keystroke
328333
@keysDown = []
329334
@cmdDown = false
330335

@@ -335,8 +340,7 @@ ui.hotkeys =
335340
return @maintainInterval()
336341

337342
else if keystroke in ['shift', 'alt', 'ctrl']
338-
@modifiersDown = @modifiersDown.remove keystroke
339-
ui.uistate.get('tool').deactivateModifier keystroke
343+
@registerModifierUp keystroke
340344
return @maintainInterval()
341345
else
342346
@keysDown = @keysDown.remove keystroke
@@ -404,17 +408,8 @@ ui.hotkeys =
404408

405409
parseKeystroke: (e) ->
406410

407-
modifiers =
408-
8: 'backspace'
409-
16: 'shift'
410-
17: 'ctrl'
411-
18: 'alt'
412-
91: 'cmd'
413-
92: 'cmd'
414-
224: 'cmd'
415-
416-
if modifiers[e.which]?
417-
return modifiers[e.which]
411+
if @modifierCodes[e.which]?
412+
return @modifierCodes[e.which]
418413

419414
accepted = [
420415
new Range(9, 9) # Enter

src/less/ui.less

+16
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ body {
8989
cursor: none!important;
9090
}
9191
}
92+
93+
.⌘ {
94+
&:after {
95+
content: '';
96+
}
97+
}
98+
99+
&[os="windows"] {
100+
.⌘ {
101+
&:after {
102+
content: 'ctrl';
103+
margin: auto 2px;
104+
letter-spacing: -0.01em;
105+
}
106+
}
107+
}
92108
}
93109

94110
div#canvas {

0 commit comments

Comments
 (0)