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-description
function. – dshepherd Jun 04 '15 at 21:56kill-ring
contains. Do you mean thekey-description
string? or the return value of the aboveformat
sexp? 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-RET
orM-<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:46kbd
in theglobal-set-key
sexp - corrected now.) Commandfoo
(which theglobal-set-key
sexp binds toC-c c
) reads a key sequence and then inserts, at point of the current buffer, the properkbd
sexp for it. If you useC-c c
in your init file, after(local-set-key
, then it inserts thekbd
sexp you need for the key it reads. – Drew Jun 27 '15 at 20:46kbd
sexp 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