chenbo007 / svg-edit

Automatically exported from code.google.com/p/svg-edit
0 stars 0 forks source link

Correctly map keyboard shortcuts for OSX/Windows/Linux #84

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Currently shortcuts are tied to raw keystrokes:  

  * N for New
  * C for Clone
  * S for Save
  * U for source
  * Z for Undo
  * etc

It would be better to map these using the proper modifier key depending on
the platform.  For browsers in Windows and Linux, the modifier key would be
Ctrl (Ctrl+N, etc).  For browsers in OSX, the modifier key would be Cmd (meta).

So:

1) figure out a way to determine the platform

2) adjust most key bindings to include the proper modifier key

3) update all tooltips to include the proper modifier key

Original issue reported on code.google.com by codedr...@gmail.com on 7 Aug 2009 at 5:31

GoogleCodeExporter commented 9 years ago
1) figure out a way to determine the platform

    var isMac = (navigator.platform.indexOf("Mac") != -1);

For 2 & 3) I've done this in my working copy and it works as expected in 
Firefox and
Safari.  Unfortunately, neither Chrome or Opera play nice with this.

So options are:  

a) leave key bindings as they are (so they are consistent across browsers

b) bind to ctrl+/meta+ in firefox and safari only

I'm going with option a) right now.

Original comment by codedr...@gmail.com on 7 Aug 2009 at 7:04

GoogleCodeExporter commented 9 years ago

Original comment by codedr...@gmail.com on 11 Aug 2009 at 2:47

GoogleCodeExporter commented 9 years ago
Alright, here's my fairly extensive testing on ctrlKey and metaKey on Mac OSX 
for the latest versions of all browsers. Tested for keypress, keyup and keydown 
events, which often influence each other depending on which is set. Also tested 
whether preventDefault works.

Safari:
metaKey: Only keypress if keydown is not set, never fires for keyup
ctrlKey: Only keypress if keydown is not set

Opera: - Fires metaKey for ctrlKey and ctrlKey for metaKey! Crazy!
metaKey: Only keydown and keypress, CANNOT prevent default
ctrlKey: Only keydown and keypress

Firefox
metaKey: Only keydown and keypress
ctrlKey: All

Chrome:
metaKey: Only keydown, CANNOT prevent default
ctrlKey: keypress only on SOME keys, keydown and keyup on all

No tests have yet been done in conjunction with the hotkey script, figured I 
should test basic support first.

Original comment by adeve...@gmail.com on 27 Sep 2010 at 7:49

GoogleCodeExporter commented 9 years ago
So it comes down to this: Use only keydown, and keep in mind CMD+(anything) 
cannot prevent the default behavior in Opera or Chrome. However the cut, copy & 
paste keys should be harmless to use, so I say we still use CMD+ for them, and 
be careful with others. 

Original comment by adeve...@gmail.com on 27 Sep 2010 at 8:25

GoogleCodeExporter commented 9 years ago
One alternative is to support both -- Ctrl and Cmd -- and then whichever one 
people try to use, it works for them.

Original comment by ashe...@asheesh.org on 6 Apr 2013 at 3:38