mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-13 23:59:20 +08:00
feat: support Emacs/Vim navigation in command line (#4019) clo4
* feat: support ctrl-n/p/j/k in command line This allows for both emacs and vim style navigation, which is muscle memory for a lot of people but currently unsupported in the main list view people use. Supporting both feels a lot more natural, and makes navigation easier for people that either don't have arrow keys at all or on their main layer * fix comment * flip conditions to check ctrl first This is more likely to short circuit faster because ctrl isn't the common case
This commit is contained in:
parent
3f8e09ba3b
commit
cb7d1ce509
1 changed files with 15 additions and 3 deletions
|
|
@ -669,7 +669,14 @@ $(document).on("keydown", (e) => {
|
|||
trigger(command);
|
||||
return;
|
||||
}
|
||||
if (e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "Tab") {
|
||||
if (
|
||||
e.key === "ArrowUp" ||
|
||||
e.key === "ArrowDown" ||
|
||||
e.key === "Tab" ||
|
||||
// Should only branch if ctrl is held to allow the letters to still be typed
|
||||
(e.ctrlKey &&
|
||||
(e.key === "p" || e.key === "n" || e.key === "j" || e.key === "k"))
|
||||
) {
|
||||
e.preventDefault();
|
||||
$("#commandLineWrapper #commandLine .suggestions .entry").unbind(
|
||||
"mouseenter mouseleave"
|
||||
|
|
@ -682,7 +689,10 @@ $(document).on("keydown", (e) => {
|
|||
});
|
||||
if (
|
||||
e.key === "ArrowUp" ||
|
||||
(e.key === "Tab" && e.shiftKey && Config.quickRestart !== "esc")
|
||||
(e.key === "Tab" && e.shiftKey && Config.quickRestart !== "esc") ||
|
||||
// Don't need to check for ctrl because that was already done above
|
||||
e.key === "p" ||
|
||||
e.key === "k"
|
||||
) {
|
||||
entries.removeClass("activeKeyboard");
|
||||
if (activenum == 0) {
|
||||
|
|
@ -695,7 +705,9 @@ $(document).on("keydown", (e) => {
|
|||
}
|
||||
if (
|
||||
e.key === "ArrowDown" ||
|
||||
(e.key === "Tab" && !e.shiftKey && Config.quickRestart !== "esc")
|
||||
(e.key === "Tab" && !e.shiftKey && Config.quickRestart !== "esc") ||
|
||||
e.key === "n" ||
|
||||
e.key === "j"
|
||||
) {
|
||||
entries.removeClass("activeKeyboard");
|
||||
if (activenum + 1 == entries.length) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue