Skip to content

Create CommandOrControl so ctrl+c in Windows == command+c in Mac #83733

Open

Description

@bernaferrari

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).

Activity

  1. changed the title [-]LogicalKeyboardKey[/-] [+]LogicalKeyboardKey ctrl+c in Windows != command+c in Mac[/+] on Jun 1, 2021
  2. added
    in triagePresently being triaged by the triage team
    engineflutter/engine related. See also e: labels.
    c: proposalA detailed proposal for a change to Flutter
    a: text inputEntering text in a text field or keyboard related problems
    and removed
    in triagePresently being triaged by the triage team
    on Jun 2, 2021
  3. HansMuller commented on Jun 2, 2021

    @HansMuller
    Contributor
  4. dkwingsmt commented on Jun 2, 2021

    @dkwingsmt
    Contributor

    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.

  5. added
    P3Issues that are less important to the Flutter project
    on Jun 2, 2021
  6. bernaferrari commented on Jun 25, 2021

    @bernaferrari
    ContributorAuthor

    Hey @dkwingsmt, that code wouldn't work because there is no dart:IO in Flutter Web, so it would be even more complicated.

  7. csells commented on Sep 9, 2021

    @csells
    Contributor

    cc @cbracken to consider for the desktop stable release

  8. dkwingsmt commented on Sep 9, 2021

    @dkwingsmt
    Contributor

    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

    OsSingleActivator(
      this.osControl,
      this.osMeta,
    ...);
    

    Or

    AdaptiveSingleActivator(
      this.primary,
      this.auxiliary,
    ...);
    
  9. bernaferrari commented on Sep 11, 2021

    @bernaferrari
    ContributorAuthor

    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.

  10. cbracken commented on Sep 28, 2021

    @cbracken
    Member

    /cc @justinmc for comments. Is there an existing bug for this? Alternatively, does an alternative solution for this already exist?

  11. justinmc commented on Sep 28, 2021

    @justinmc
    Contributor

    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.

  12. bernaferrari commented on Dec 8, 2021

    @bernaferrari
    ContributorAuthor

    Idea 2: we could somehow unify 'delete' with 'backspace' as they are the same shortcut 98% of the time.

  13. peter-trost commented on Jul 25, 2024

    @peter-trost
    Contributor

    I face this issue just now and would really like an easier interface. How about "platformControl" and "platformMeta"?

  14. AlabasterAxe commented on Sep 13, 2024

    @AlabasterAxe

    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.

    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.

  15. 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
  16. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: text inputEntering text in a text field or keyboard related problemsc: proposalA detailed proposal for a change to Flutterengineflutter/engine related. See also e: labels.team-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions