I'd like to get the string representation of a keymap event. For instance 19 should be printed as C-s, 1 as C-a etc...

I could make my own function to do that but since describe-keyis capable of printing the string representation of an event there must be a built-in function to do that somewhere. I looked into the manual and browsed some code and was not able to found it.


1 Answer 1


If a single key/character, just use function single-key-description.

(single-key-description 19) ; => "C-s"

If a list of characters, convert them to a string and use function key-description.

(key-description (string 19 25 20 5 43)) ; => "C-s C-y C-c C-e +"

If a key sequence as a string, use function key-description. (Here I write "^Y" etc when I mean the string with a single control char, ^Y.)

(key-description "^S^Y^T^e+") ; => "C-s C-y C-c C-e +"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.