I'm bored of looking up key names for the kbd function, is there a way to automatically insert the correct key name just by pressing the key?
So for example I want something to do this: I'm typing
(local-set-key |
I run magical-insert-kbd-command, press f6 and I get
(local-set-key (kbd "<f6>") |
key-descriptionfunction. – dshepherd Jun 04 '15 at 21:56kill-ringcontains. Do you mean thekey-descriptionstring? or the return value of the aboveformatsexp? Anyway, it should be clear how to modify the command I gave, to add either of those to thekill-ring(just usekill-new). – Drew Jun 27 '15 at 15:48kbd <M-return>) but does not insert it into an init file. (You'd have to do the additional step of copy/paste.) Maybe I misunderstood. For my own personal use case, I would find it useful to have a way to query the syntax for a keybinding (e.g. is the syntaxM-RETorM-<return>or what?) and automatically place that string in the kill ring/pasteboard, so that I could then paste the keybinding into my init file when writing a line like(define-key map (kbd "<M-return>") 'org-return). – incandescentman Jun 27 '15 at 20:46kbdin theglobal-set-keysexp - corrected now.) Commandfoo(which theglobal-set-keysexp binds toC-c c) reads a key sequence and then inserts, at point of the current buffer, the properkbdsexp for it. If you useC-c cin your init file, after(local-set-key, then it inserts thekbdsexp you need for the key it reads. – Drew Jun 27 '15 at 20:46kbdsexp would be. It does that. It inserts that sexp in the current buffer at point. – Drew Jun 27 '15 at 21:00(format "(kbd %S) …)"is more robust. It will escape any"(or backslashes, etc.) in the key sequence provided. – Harald Hanche-Olsen Jun 29 '15 at 14:15keybinding-read-and-insert. – incandescentman Jul 09 '15 at 16:33