Skip to content

feat(ui): add Ctrl+N/P navigation in command palette#2549

Closed
jcalixte wants to merge 6 commits intonpmx-dev:mainfrom
jcalixte:feat/command-palette-ctrl-n-p-nav
Closed

feat(ui): add Ctrl+N/P navigation in command palette#2549
jcalixte wants to merge 6 commits intonpmx-dev:mainfrom
jcalixte:feat/command-palette-ctrl-n-p-nav

Conversation

@jcalixte
Copy link
Copy Markdown

@jcalixte jcalixte commented Apr 16, 2026

Hi, I propose the shortcuts in the Command Palette ctrl+n/p for list navigation that can be a good fit for keyboard-heavy users for list navigation without affecting anyone else.

Disclaimer : I've primarly used Claude Code to generate this Pull Request.

Summary

  • Adds Emacs Ctrl+N (next) and Ctrl+P (previous) as alternative navigation shortcuts in the command palette, alongside the existing ArrowDown/ArrowUp keys
  • Updates the command_palette.instructions i18n string to mention Ctrl+N/P

Implementation

The two existing ArrowDown/ArrowUp conditions in handleGlobalKeydown were extended with an || clause — minimal change with no logic duplication. I reused the existing getCommandElements(), focusCommand(), and focusInput() helpers.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs.npmx.dev Ready Ready Preview, Comment Apr 17, 2026 10:17am
npmx.dev Ready Ready Preview, Comment Apr 17, 2026 10:17am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
npmx-lunaria Ignored Ignored Apr 17, 2026 10:17am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 16, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5a3626ef-d7e4-408b-89e1-66ffa603b43c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Added Ctrl+N and Ctrl+P keyboard shortcuts to the command palette so they behave like ArrowDown/ArrowUp while the palette is open; updated the English instruction string to mention these shortcuts.

Changes

Cohort / File(s) Summary
Command palette & i18n
app/components/CommandPalette.client.vue, i18n/locales/en.json
Implemented Ctrl+N → next result and Ctrl+P → previous result handling in the global keydown handler (preventDefault, move focus, return early). Updated command_palette.instructions to mention "arrow keys or Ctrl+N/P".

Suggested reviewers

  • whitep4nth3r
  • danielroe
  • ghostdevv
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding Ctrl+N/P navigation shortcuts to the command palette.
Description check ✅ Passed The pull request description clearly relates to the changeset, detailing the addition of Ctrl+N/P shortcuts in the command palette and corresponding i18n updates.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

Hello! Thank you for opening your first PR to npmx, @jcalixte! 🚀

Here’s what will happen next:

  1. Our GitHub bots will run to check your changes.
    If they spot any issues you will see some error messages on this PR.
    Don’t hesitate to ask any questions if you’re not sure what these mean!

  2. In a few minutes, you’ll be able to see a preview of your changes on Vercel

  3. One or more of our maintainers will take a look and may ask you to make changes.
    We try to be responsive, but don’t worry if this takes a few days.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 16, 2026

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
i18n/locales/en.json Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/components/CommandPalette.client.vue (1)

176-185: ⚠️ Potential issue | 🟡 Minor

Constrain Ctrl+N/P to the exact shortcut combo.

Lines 176 and 185 currently match any Ctrl+N/P variant, including when combined with Alt, Meta, or Shift. This can unintentionally trigger navigation for unrelated keyboard shortcuts whilst the palette is open. The codebase establishes the pattern of explicitly guarding against unwanted modifiers (see lines 160–164 for the toggle shortcut and lines 199–205 for the escape handler), so these handlers should follow the same convention.

Suggested patch
-  if (event.key === 'ArrowDown' || (event.ctrlKey && event.key.toLowerCase() === 'n')) {
+  if (
+    event.key === 'ArrowDown' ||
+    (event.ctrlKey &&
+      !event.altKey &&
+      !event.metaKey &&
+      !event.shiftKey &&
+      event.key.toLowerCase() === 'n')
+  ) {
@@
-  if (event.key === 'ArrowUp' || (event.ctrlKey && event.key.toLowerCase() === 'p')) {
+  if (
+    event.key === 'ArrowUp' ||
+    (event.ctrlKey &&
+      !event.altKey &&
+      !event.metaKey &&
+      !event.shiftKey &&
+      event.key.toLowerCase() === 'p')
+  ) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/components/CommandPalette.client.vue` around lines 176 - 185, The
Ctrl+N/P handlers currently match any combination that includes Ctrl (e.g.,
Ctrl+Alt+N) because they only check event.ctrlKey and key; update both keyboard
handlers (the ArrowDown block that uses getCommandElements, flatCommands.value
and focusCommand, and the ArrowUp block) to require exactly Ctrl with no other
modifiers by adding checks !event.altKey && !event.metaKey && !event.shiftKey in
the condition (keep the event.key.toLowerCase() === 'n' / 'p' checks) so
navigation only triggers for the precise Ctrl+N and Ctrl+P shortcuts.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@app/components/CommandPalette.client.vue`:
- Around line 176-185: The Ctrl+N/P handlers currently match any combination
that includes Ctrl (e.g., Ctrl+Alt+N) because they only check event.ctrlKey and
key; update both keyboard handlers (the ArrowDown block that uses
getCommandElements, flatCommands.value and focusCommand, and the ArrowUp block)
to require exactly Ctrl with no other modifiers by adding checks !event.altKey
&& !event.metaKey && !event.shiftKey in the condition (keep the
event.key.toLowerCase() === 'n' / 'p' checks) so navigation only triggers for
the precise Ctrl+N and Ctrl+P shortcuts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 995477e0-7fdd-4113-af74-7f79efe65f8d

📥 Commits

Reviewing files that changed from the base of the PR and between 75bce20 and c1969c4.

📒 Files selected for processing (2)
  • app/components/CommandPalette.client.vue
  • i18n/locales/en.json

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@jhroemer
Copy link
Copy Markdown
Contributor

@jcalixte I agree that the arrow-keys are awkward, but tab works well for me at least. Any reason this doesn't work for you?

I'd personally be a bit hesitant about adding something emacs specific (I'm not an emacs user, but I understand N/P is emacs specific?), or I would then at least question if we should also, or instead, support vim-like j or k shortcuts. There are also browser extensions that allow some of these things (I use Vimium myself), and there might be a line to draw between what's supported by default and what's user specific.

To be clear, not saying to do one or the other, just questioning whether adding emacs specific modifiers as a default is too opinionated.

@jcalixte
Copy link
Copy Markdown
Author

Hi @jhroemer, thanks for taking time for answering me!

I completely forgot that the tab / shift+tab was a possibility as I'm learning new ways to develop others than in VS Code, I may have been in a rabbit hole these past months 🫣

I agree with you that this feature may be too opinionated.

If you agree, I'll close this PR then.

Thank you!

@jcalixte jcalixte closed this Apr 17, 2026
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

Successfully merging this pull request may close these issues.

2 participants