I was wondering if there is a reverse (kbd) function, one I could use to get from a keycode a meaningful description of it, e.g., C-b from 2.
Usually (format "%c" x) does work, but not for the previous example as well as for many others, as keybindings, specially on Emacs, are often more complicated than a single character, and even when they are indeed a single character, they can be a whitespace or a Tab.
It seems that the documentation functions use themselves the function (describe-buffer-bindings), which is written in C and therefore immutable, and I'd like to avoid that route, if possible, and manipulate the data in my way to provide fancier features.
You're probably looking for (key-description KEYS &optional PREFIX).
For example: (key-description [2]) and (key-description (kbd "C-b")) evaluate to "C-b".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With