Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new key binding (like ctrl-p and ctrl-n) to select adjacent search items #3853

Open
4 tasks done
shellRaining opened this issue May 2, 2024 · 7 comments
Open
4 tasks done

Comments

@shellRaining
Copy link
Contributor

Is your feature request related to a problem? Please describe.

just an enhancement , I found I can't select next item when type ctrl-n

Describe the solution you'd like

add Ctrl-n binding to select the next search item, while Ctrl-p to select prev.

Describe alternatives you've considered

No response

Additional context

I really like this project, and also like the Vim-style key bindings. So I wish to add these two mappings.

I really hope to be able to participate in this project. If this enhancement is adopted, I am happy to submit a PR~

Validations

@brc-dd
Copy link
Member

brc-dd commented May 2, 2024

Why do you want to select search results? 👀 Do you want to avoid doing arrow down/up + return?

Moreover ctrl/cmd + p is for printing and ctrl/cmd + n is for new window. It would conflict with those.

@shellRaining
Copy link
Contributor Author

I often use the search function.

First, press Ctrl-k to open the search box
then enter the search text, and then use the up or down keys to select a matching entry.
Finally, press Enter to view the full article.

However, up or down are quite far away. I hope I can use Ctrl-n or Ctrl-p instead.

@shellRaining
Copy link
Contributor Author

Why do you want to select search results? 👀 Do you want to avoid doing arrow down/up + return?

Moreover ctrl/cmd + p is for printing and ctrl/cmd + n is for new window. It would conflict with those.

Oh, sorry, I am using a Mac keyboard. I forgot that Ctrl n and Ctrl p are browser shortcuts.

That seems not a good suggestion.

@brc-dd
Copy link
Member

brc-dd commented May 2, 2024

However, up or down are quite far away.

? They are literally reachable without stretching hand!

image

@shellRaining
Copy link
Contributor Author

Can we just do this key mapping for Mac, I found that Next.js documentation can use shortcuts like Ctrl-n

@shellRaining
Copy link
Contributor Author

However, up or down are quite far away.

? They are literally reachable without stretching hand!

Moving the little finger to up or down will make the right hand leave its original position, I think it's uncomfortable 😂

@NReilingh
Copy link

I am also on mac and I have adopted ctrl-p and ctrl-n for previous/next when selecting from a list. This pattern of shortcuts originates from unix shells (common for navigating bash/zsh history) and is also one of the set of emacs-originated shortcuts which are built in to macos system text fields (for example, the safari location bar supports ctrl-a, ctrl-e for moving the cursor to the beginning and end of the field, and ctrl-p/ctrl-n for selecting from the autocomplete options which can be presented from the location bar.

These shortcuts work similarly in chrome, and are also adopted by many other apps' search fields like Discord and Alfred as well as web apps like Github.

On macOS these do not conflict with print/new like they do on windows; I do not know whether it is more common to override them or just let them not affect windows; I suspect the latter, especially for web apps. Anyhow, I think implementing this behavior equivalent to how it works in Github's search field would be a great addition, and will particularly impress folks who live in the terminal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants