Skip to content

Support for ⌃P (select up) and ⌃N (select down) in lists #7266

Done

Description

@erusev

By lists, I mean Repo list (⌘T), Branches list (⌘B), etc.

These are standard shortcuts in lists in MacOS.

See Spotlight for example.

Activity

  1. billygriffin commented on Apr 12, 2019

    @billygriffin
    Contributor

    Thanks @erusev! I'm curious if there's a reason why arrow keys aren't sufficient for navigating through lists, or if it's personal preference based on muscle memory from other apps?

  2. added
    more-info-needed
    on Apr 12, 2019
  3. erusev commented on Apr 12, 2019

    @erusev
    Author

    Sure, the main reason is that in order to use arrow keys you have to move your hand and this is significantly slower.

    Also, since these alternative shortcuts are quite common across MacOS apps, they are muscle memory for people who use them and not having them available feels frustrating.

  4. added
    macOS
    on Apr 15, 2019
  5. erusev commented on Apr 17, 2019

    @erusev
    Author

    Here's some more info on these and other emacs shortcuts supported in MacOS: https://jblevins.org/log/kbd.

  6. removed
    more-info-needed
    on Apr 24, 2019
  7. shiftkey commented on Apr 24, 2019

    @shiftkey
    Member

    I started on a rough patch to see what it would take to get this working:

    diff --git a/app/src/ui/lib/list/list.tsx b/app/src/ui/lib/list/list.tsx
    index e8d6fe970..733fc5466 100644
    --- a/app/src/ui/lib/list/list.tsx
    +++ b/app/src/ui/lib/list/list.tsx
    @@ -379,7 +379,16 @@ export class List extends React.Component<IListProps, IListState> {
           return
         }
     
    -    if (event.key === 'ArrowDown') {
    +    const { key, ctrlKey } = event
    +
    +    // macOS also supports emacs-inspired shortcuts for moving up/down lists
    +    // see https://jblevins.org/log/kbd for more information
    +    const isArrowDown =
    +      key === 'ArrowDown' || (__DARWIN__ && ctrlKey && key === 'n')
    +    const isArrowUp =
    +      event.key === 'ArrowUp' || (__DARWIN__ && ctrlKey && key === 'p')
    +
    +    if (isArrowDown) {
           if (
             event.shiftKey &&
             this.props.selectionMode &&
    @@ -390,7 +399,7 @@ export class List extends React.Component<IListProps, IListState> {
             this.moveSelection('down', event)
           }
           event.preventDefault()
    -    } else if (event.key === 'ArrowUp') {
    +    } else if (isArrowUp) {
           if (
             event.shiftKey &&
             this.props.selectionMode &&

    There's a few other places in the codebase where we look for 'ArrowDown' or 'ArrowUp' events, but I think this is an interesting issue for a contributor with macOS who wants to improve these interactions to take a shot at this, so I'm going to mark this as help-wanted.

  8. added
    help wanted
    on Apr 24, 2019
  9. narsaynorath commented on Oct 5, 2019

    @narsaynorath

    Hi all, I made a PR that implements @shiftkey's idea in the files where ArrowDown or ArrowUp are used. Let me know if there's any feedback or if there might be tests I need to update.

  10. agisilaos commented on Dec 13, 2021

    @agisilaos
    Member

    @niik I'm planning to work on this so I'm assigning myself.

  11. self-assigned this
    on Dec 13, 2021
  12. added a commit that references this issue on Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

help wantedmacOS

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions