Skip to content

Instantly share code, notes, and snippets.

@pabloariasal
Created July 25, 2025 19:30
Show Gist options
  • Save pabloariasal/e0b65c5c158b436a1685f69624d629f2 to your computer and use it in GitHub Desktop.
Save pabloariasal/e0b65c5c158b436a1685f69624d629f2 to your computer and use it in GitHub Desktop.
dmenu custom keybindings
diff --git a/dmenu.1 b/dmenu.1
index 323f93c..44ab98f 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -84,9 +84,6 @@ embed into windowid.
dmenu is completely controlled by the keyboard. Items are selected using the
arrow keys, page up, page down, home, and end.
.TP
-.B Tab
-Copy the selected item to the input field.
-.TP
.B Return
Confirm selection. Prints the selected item to stdout and exits, returning
success.
@@ -131,15 +128,12 @@ Escape
Backspace
.TP
.B C\-i
-Tab
-.TP
-.B C\-j
-Return
+Copy the selected item to the input field.
.TP
.B C\-J
Shift-Return
.TP
-.B C\-k
+.B C\-l
Delete line right
.TP
.B C\-m
@@ -148,6 +142,18 @@ Return
.B C\-M
Shift-Return
.TP
+.B C\-j
+Down
+.TP
+.B C\-k
+Up
+.TP
+.B Tab
+Down
+.TP
+.B C\-Tab
+Up
+.TP
.B C\-n
Down
.TP
diff --git a/dmenu.c b/dmenu.c
index fd49549..e8bff20 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -349,15 +349,17 @@ keypress(XKeyEvent *ev)
case XK_f: ksym = XK_Right; break;
case XK_g: ksym = XK_Escape; break;
case XK_h: ksym = XK_BackSpace; break;
- case XK_i: ksym = XK_Tab; break;
- case XK_j: /* fallthrough */
+ case XK_i: ksym = XK_Insert; break;
case XK_J: /* fallthrough */
case XK_m: /* fallthrough */
case XK_M: ksym = XK_Return; ev->state &= ~ControlMask; break;
+ case XK_j: /* fallthrough */
case XK_n: ksym = XK_Down; break;
+ case XK_k: /* fallthrough */
+ case XK_Tab: /* fallthrough */
case XK_p: ksym = XK_Up; break;
- case XK_k: /* delete right */
+ case XK_l: /* delete right */
text[cursor] = '\0';
match();
break;
@@ -507,13 +509,14 @@ insert:
return;
/* fallthrough */
case XK_Down:
+ case XK_Tab:
case XK_KP_Down:
if (sel && sel->right && (sel = sel->right) == next) {
curr = next;
calcoffsets();
}
break;
- case XK_Tab:
+ case XK_Insert:
if (!sel)
return;
cursor = strnlen(sel->text, sizeof text - 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment