Oh, right. Sorry, hadn't had my coffee yet.
I tried doing exactly that, but used (interactive "kKey: "), with lowercase k, and it didn't work.
I tried doing exactly that, but used (interactive "kKey: "), with lowercase k, and it didn't work.
I much prefer formatting the keybindings like kbd uses, anyway - do you know offhand how to convert a keypress to that format w/out using C-h k?
This should do what the original commenter wanted:
(defun insert-keybinding (k)
"Insert code for a keybinding."
(interactive "kKey sequence: ")
(insert (concat "(global-set-key (kbd \""
(key-description k)
"\") 'function-name)")))