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)")))
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?