0

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?

3

I 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)
0

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:

  1. F1 is bound
  2. It needs to be lower case

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 :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.