Preferences

You mean something like which-key? It existed for a long time as an external package and was added to main emacs recently. https://github.com/emacs-mirror/emacs/commit/fa4203300fde682...

Alternatively beside which-key, hydras exist which are very nice for certain contexts (dired in the particular case for me) and provide a nice shortcut interface whenever activated. Demo at [0].

[0]: https://www.youtube.com/watch?v=_qZliI1BKzI

setopt
As far as I know, which-key only helps with key sequences. If you press C-c in Org-mode it will show you keys like C-c C-e, but if you hold Ctrl down it won’t show you C-RET for example.
iLemming
Emacs can't do that for historic reasons. It just can't distinguish between keypress and keyup events. It receives input events from the terminal/OS. Terminals are text-oriented: They evolved to transmit characters, not hardware events.

It's not some technical impossibility - I think it would make sense to make this possible, at least in GUI Emacs. I suppose there was never a strong incentive to tackle this problem.

skydhash
A good shortcut is "C-h m" which shows the help for the major mode (and current active minor modes). It will also shows all the bindings that those modes define.
pama OP
If you want all keybindings, C-h b typically helps, and you can search within the single buffer it returns. Every key in Emacs is bound to something, but a plain modifier key event like Ctrl will not be sent from a terminal to any command that runs inside it, eg Emacs, only the modified key. (There exist modifications/extensions of this protocol, eg kitty, but most combinations wouldnt see these events.)
setopt
Sure, I know about C-h b and C-h m and find those useful. But I think what the GP post describes is more contextual: A way to not display every keybinding, but only those directly accessible by pressing the currently held modifier combo followed by one key (so holding Ctrl+Meta for more than a couple of seconds might remind you of all structural editing commands for example).

This is indeed not possible in a classical terminal emulator (don’t know if kkp for example has extensions for it). But most GUI apps can detect individual modifiers being pressed and released, even as separate events. Some editors like VSCode can also bind modifier taps to actions using this ability. In Emacs however this is AFAIK not possible even in the GUI, because of how keybindings are handled deep down.

The UI pattern described by the GP does exist in some other apps and platforms. For example, if you connect an external keyboard to an iPad, holding down the Cmd modifier for a couple of seconds will show you a popup which-key-like overview of all Cmd+key keybindings.

pama OP
Agreed. I keep almost all things same between terminal and graphical UI, so I would never use it, but I can see the appeal of having the ability for handling keyboard events differently than character inputs in some cases in the GUI.

This item has no comments currently.