From 0a8aac26c2838f1d72ad4f057369205c647f46fb Mon Sep 17 00:00:00 2001 From: xaskii Date: Mon, 7 Oct 2024 07:40:49 -0400 Subject: [PATCH] impr(command line): add 'ctrl p' and 'ctrl n' navigation key binds (@xaskii) (#5949) ### Description Adds `` and `` binds to the command-line. These are from Emacs, but you can navigate up and down menus all over macOS and its apps with these keybinds. #### Relevant PRs Refactor that removed the binds: https://github.com/monkeytypegame/monkeytype/pull/5180 adding "vim keybinds": https://github.com/monkeytypegame/monkeytype/pull/4019 Confirmed working on macOS (safari, firefox, and chrome). On windows, ``: opening a new window takes priority, but that's expected behaviour. ### Checks - [ ] Adding quotes? - [ ] Make sure to include translations for the quotes in the description (or another comment) so we can verify their content. - [ ] Adding a language or a theme? - [ ] If is a language, did you edit `_list.json`, `_groups.json` and add `languages.json`? - [ ] If is a theme, did you add the theme.css? - Also please add a screenshot of the theme, it would be extra awesome if you do so! - [x] Check if any open issues are related to this PR; if so, be sure to tag them below. - [x] Make sure the PR title follows the Conventional Commits standard. (https://www.conventionalcommits.org for more info) - [x] Make sure to include your GitHub username prefixed with @ inside parentheses at the end of the PR title. Closes issue discussed in discord. --- frontend/src/ts/commandline/commandline.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/ts/commandline/commandline.ts b/frontend/src/ts/commandline/commandline.ts index b26237da0..02a634aeb 100644 --- a/frontend/src/ts/commandline/commandline.ts +++ b/frontend/src/ts/commandline/commandline.ts @@ -619,11 +619,19 @@ const modal = new AnimatedModal({ input.addEventListener("keydown", async (e) => { mouseMode = false; - if (e.key === "ArrowUp" || (e.key.toLowerCase() === "k" && e.ctrlKey)) { + if ( + e.key === "ArrowUp" || + (e.ctrlKey && + (e.key.toLowerCase() === "k" || e.key.toLowerCase() === "p")) + ) { e.preventDefault(); await decrementActiveIndex(); } - if (e.key === "ArrowDown" || (e.key.toLowerCase() === "j" && e.ctrlKey)) { + if ( + e.key === "ArrowDown" || + (e.ctrlKey && + (e.key.toLowerCase() === "j" || e.key.toLowerCase() === "n")) + ) { e.preventDefault(); await incrementActiveIndex(); }