Wrong mapping for cmd, alt, shift, ctrl keys on macOS? #1748

Open
nicolas-p opened this Issue Nov 15, 2016 · 11 comments

Projects

None yet

2 participants

@nicolas-p
Contributor

I already saw that quite a long time ago but I wasn't too sure at the time.

It seems that on my Mac running Sierra (but already in El Capitan), the CMD key is mapped to A+ in Factor (which is supposed to be ALT).

environment-gadget "general" f {
    { T{ key-down f { A+ } "s" } save-skov-image }
} define-command-map

With the code, ALT+S does nothing but CMD+S triggers the action.

I know that CTRL is correctly mapped to C+ but CMD, ALT and SHIFT might be all wrong.

@mrjbq7
Member
mrjbq7 commented Nov 15, 2016

I think ALT (using fn+OPT) generates a M+ modifier.

@nicolas-p
Contributor

But the documentations says:

M+
Meta key modifier. This is the Command key on Mac OS X

@mrjbq7
Member
mrjbq7 commented Nov 15, 2016

Hmm...

@mrjbq7
Member
mrjbq7 commented Nov 15, 2016

Are you suggesting fixing the documentation or the code?

@nicolas-p
Contributor

The docs seem fine, it's logical that:
M+ = Meta
A+ = Alt
S+ = Shift
C+ = Ctrl

If the code says M+ = Alt and A+ = Meta, that's super strange!

@mrjbq7
Member
mrjbq7 commented Nov 15, 2016

Well, I mean that the documentation about Mac does not match the code. These are the mappings on macOS:

  • S+ = Shift
  • C+ = Control
  • A+ = Command
  • M+ = Alt

https://github.com/factor/factor/blob/master/basis/ui/backend/cocoa/views/views.factor#L36

I think it was probably done because ALT is annoying to type, and CMD is used like ALT on other platforms.

@nicolas-p
Contributor

Was this done so that keyboard shortcuts automatically respect platform-specific conventions? In this case I would expect Control on Windows = Command on Mac.

@mrjbq7
Member
mrjbq7 commented Nov 15, 2016

It was definitely done to help users make cross-platform applications. For example, in the Listener we do a single binding for A+L to create a new listener window which is Cmd-L on the Mac (convenient) and Alt-L on other platforms.

Any suggestions at making it easier, simpler, more explicit, etc. are welcome.

@nicolas-p
Contributor

Then I would have intuitively chosen:

MacWindows
CommandControl
ControlWindows
AltAlt
ShiftShift

But at least if the code stays the way it is, the documentation should be corrected.

@mrjbq7
Member
mrjbq7 commented Nov 15, 2016

Yeah, the problem is that Alt on Windows is typically used as a menu accelerator key (which is what Command is often used for on Mac). It's messy.

@nicolas-p
Contributor

Yes, there's probably no good way to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment