From a93b2d922c3b912e89b98c0985811039af665bf1 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Sun, 10 Aug 2014 08:28:27 -0400 Subject: [PATCH] On Windows, use alt modifier instead of ctrl for back/forward navigation Fixes #51. --- assets/javascripts/app/shortcuts.coffee | 19 +++++++++++++++---- .../templates/pages/help_tmpl.coffee | 7 ++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/assets/javascripts/app/shortcuts.coffee b/assets/javascripts/app/shortcuts.coffee index ebb44742..a944af43 100644 --- a/assets/javascripts/app/shortcuts.coffee +++ b/assets/javascripts/app/shortcuts.coffee @@ -2,6 +2,7 @@ class app.Shortcuts $.extend @prototype, Events constructor: -> + @isWindows = navigator.platform?.indexOf('Win') >= 0 @start() start: -> @@ -72,14 +73,16 @@ class app.Shortcuts when 13 @trigger 'superEnter' when 37 - @trigger 'superLeft' - false + unless @isWindows + @trigger 'superLeft' + false when 38 @trigger 'home' false when 39 - @trigger 'superRight' - false + unless @isWindows + @trigger 'superRight' + false when 40 @trigger 'end' false @@ -97,9 +100,17 @@ class app.Shortcuts switch event.which when 9 @trigger 'altRight', event + when 37 + if @isWindows + @trigger 'superLeft' + false when 38 @trigger 'altUp' false + when 39 + if @isWindows + @trigger 'superRight' + false when 40 @trigger 'altDown' false diff --git a/assets/javascripts/templates/pages/help_tmpl.coffee b/assets/javascripts/templates/pages/help_tmpl.coffee index 10d0bbad..53e7131e 100644 --- a/assets/javascripts/templates/pages/help_tmpl.coffee +++ b/assets/javascripts/templates/pages/help_tmpl.coffee @@ -1,4 +1,5 @@ -ctrlKey = if navigator.userAgent.indexOf 'Mac OS X' then 'cmd' else 'ctrl' +ctrlKey = if navigator.userAgent?.indexOf('Mac') >= 0 then 'cmd' else 'ctrl' +navKey = if navigator.platform?.indexOf('Win') >= 0 then 'alt' else ctrlKey app.templates.helpPage = """
@@ -59,8 +60,8 @@ app.templates.helpPage = """

Navigation

- #{ctrlKey} + ← - #{ctrlKey} + → + #{navKey} + ← + #{navKey} + →
Go back/forward
alt + ↓