You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Create CommandOrControl so ctrl+c in Windows == command+c in Mac #83733
LogicalKeyboardKey's controlLeft on Windows and Linux means ctrl (like ctrl+c), but on macOS control is something else entirely different. For things like ctrl+c, the correct is command+c, which is Windows' Windows key (metaLeft). This gets instantly confusing.
I've seen apps with shortcuts broken because the developer only tested on Windows/Mac and didn't realize control works completely different across both.
My suggestions: somehow we could have a LogicalKeyboardKey "correct/expected" control and meta so developers and users wouldn't be confused or even worry about it. This affects even Flutter Web. No one is going to do if (Platform.macOS) metaLeft else controlLeft because it is going to take too long for them to realize this is necessary. It seems like a bug, even though the logical key is 100% correct (from logical point of view).
I agree, I also think the if (Platform.macOS) metaLeft else controlLeft pattern is too much boilerplate. Let me see if we can come up with a utility class.
Reacted by Bernardo Ferrari, Vuong Nguyen Thien and Батмэнд Ганбаатар
Yeah I've been considering this for a while. It's not a lot to implement, and for sure important. Just hard to name.
Let's discuss naming. We need a name for the activator class, one for the "control but meta for macOS" field, and one for the "meta but control for macOS" field. My latest thought is
I prefer the first one. I like the idea of controlCommand or macOSCommand but they don't work well with meta (metaControl would be confusing 🙁) so I prefer your suggestions osControl/osMeta. Maybe instead of os it could be nativeControl but maybe native invokes the idea of something low level, which is not exactly this case.
Currently we maintain separate maps for our default text editing shortcuts. Here is Mac's meta+c and here is Windows control+c. There is no slicker way right now that I'm aware of. If this issue gets fixed maybe we can simplify those maps.
I think this issue should be renamed to something like "Create a utility to create shortcuts that use cmd on Mac and ctrl on Windows/Linux". The title as written is not a bug; ctrl+c should not be handled as cmd+c on a Mac by default.
changed the title [-]LogicalKeyboardKey ctrl+c in Windows != command+c in Mac[/-][+]Create CommandOrControl so LogicalKeyboardKey ctrl+c in Windows != command+c in Mac[/+]on Sep 13, 2024
changed the title [-]Create CommandOrControl so LogicalKeyboardKey ctrl+c in Windows != command+c in Mac[/-][+]Create CommandOrControl so ctrl+c in Windows == command+c in Mac[/+]on Sep 13, 2024
Activity
[-]LogicalKeyboardKey[/-][+]LogicalKeyboardKey ctrl+c in Windows != command+c in Mac[/+]HansMuller commentedon Jun 2, 2021
CC @dkwingsmt
dkwingsmt commentedon Jun 2, 2021
I agree, I also think the
if (Platform.macOS) metaLeft else controlLeftpattern is too much boilerplate. Let me see if we can come up with a utility class.bernaferrari commentedon Jun 25, 2021
Hey @dkwingsmt, that code wouldn't work because there is no dart:IO in Flutter Web, so it would be even more complicated.
csells commentedon Sep 9, 2021
cc @cbracken to consider for the desktop stable release
dkwingsmt commentedon Sep 9, 2021
Yeah I've been considering this for a while. It's not a lot to implement, and for sure important. Just hard to name.
Let's discuss naming. We need a name for the activator class, one for the "control but meta for macOS" field, and one for the "meta but control for macOS" field. My latest thought is
Or
bernaferrari commentedon Sep 11, 2021
I prefer the first one. I like the idea of
controlCommandormacOSCommandbut they don't work well with meta (metaControl would be confusing 🙁) so I prefer your suggestionsosControl/osMeta. Maybe instead ofosit could benativeControlbut maybe native invokes the idea of something low level, which is not exactly this case.cbracken commentedon Sep 28, 2021
/cc @justinmc for comments. Is there an existing bug for this? Alternatively, does an alternative solution for this already exist?
justinmc commentedon Sep 28, 2021
Currently we maintain separate maps for our default text editing shortcuts. Here is Mac's meta+c and here is Windows control+c. There is no slicker way right now that I'm aware of. If this issue gets fixed maybe we can simplify those maps.
bernaferrari commentedon Dec 8, 2021
Idea 2: we could somehow unify 'delete' with 'backspace' as they are the same shortcut 98% of the time.
peter-trost commentedon Jul 25, 2024
I face this issue just now and would really like an easier interface. How about "platformControl" and "platformMeta"?
AlabasterAxe commentedon Sep 13, 2024
I think this issue should be renamed to something like "Create a utility to create shortcuts that use cmd on Mac and ctrl on Windows/Linux". The title as written is not a bug;
ctrl+cshould not be handled ascmd+con a Mac by default.FWIW, Electron has a "CommandOrControl" activator for their shortcuts system which does exactly what's described here: https://www.electronjs.org/docs/latest/api/accelerator
A little wordy for my tastes but it gets the point across.
[-]LogicalKeyboardKey ctrl+c in Windows != command+c in Mac[/-][+]Create CommandOrControl so LogicalKeyboardKey ctrl+c in Windows != command+c in Mac[/+][-]Create CommandOrControl so LogicalKeyboardKey ctrl+c in Windows != command+c in Mac[/-][+]Create CommandOrControl so ctrl+c in Windows == command+c in Mac[/+]