Next: Remapping Commands, Previous: Key Bindings, Up: Mastering Key Bindings in Emacs [Index]
kbd
In order to actually bind a key you must first tell Emacs what key you intend to use. Unfortunately there’s more than one way of representing keys in Emacs: as a string, or as a vector. There is a macro built in to Emacs called kbd, which translates a human-readable key into a format Emacs can understand.
One important point to note is that you must surround function and
navigation keys with ‘<’ and ‘>’. Those keys include F-keys, arrow keys and
home row keys, like so: ‘<home>’, ‘<f8>’ and ‘<down>’. But if you want to
represent the key ‘C-c p’ then write (kbd "C-c p")
.