If I change:
(define-key org-mode-map (kbd "C-c d") 'org-toggle-todo-and-fold)
to eg:
(define-key org-mode-map (kbd "F1") 'org-toggle-todo-and-fold)
This doesn't work.
Is there a way to map to F keys such as the F1 key?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityI think any key name that's more than one character needs to be be inside <>
, so try
(define-key org-mode-map (kbd "<F1>") 'org-toggle-todo-and-fold)
Thank you for taking the time to help.
Your answer is correct in that F keys need to be enclosed in <> brackets. This is very helpful.
I had assumed though that F1 was available in emacs but it is already bound.
I then found that F5 to F9 are available to the user.
This is outlined at https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html
I also found that a lower case f must be used eg "<f5>"
Since kbd "<F1>"
would not fully work because:
I thought I would add an answer that is more complete because if I left a comment to your answer, it may not be obvious to people to see.
So:
(define-key org-mode-map (kbd "<f5>") 'org-toggle-todo-and-fold)
does work fully.
I don't mean to "steal" someone's answer though :)