As I using a non us keyboard, I want to map the capslock key as super key in emacs. I use Seil and Karabiner to map the capslock to the combination Ctrl-Alt-Cmd-Shift, which is recognized in Emacs as C-M-s. I've tried to use (define-key local-function-key-map "\C-M-s" [(super ?\ )]) but it doesn't work.

How can I map the sequence, so emacs recognizes it as Super key?

  • How did you arrive at the conclusion that Emacs recognizes it as C-M-s? In traditional emacs key notation C-M-s actually means Ctrl+Alt+s, but I suspect that you are seeing something different. C-M-s-x for example would mean Ctrl+Alt+Super+x. Did you do something like that, and then strip off the final -x?
    – nispio
    Apr 25, 2016 at 16:52
  • I assume that Seil and Karabiner will not let you map caps to super directly?
    – nispio
    Apr 25, 2016 at 17:08
  • @nispio actually I don't know, why Emacs recognize the last as super. I mapped the capslock with Seil and Karabiner to the F19 key and allocated the four mentioned buttons to it. Maybe Emacs recognize the Cmd+Shift as Super. Have to try it later. May 2, 2016 at 14:28

1 Answer 1



Your best option would be to find a way to bind CapsLock directly to Super at the Operating System level. Assuming that is not possible, you can create a "sticky" super modifier key that will allow you to use keybindings requiring a super modifier. As an example, try C-x @ s followed by some other key.

What you are trying to do is more difficult than you might expect. The reason is that Emacs most likely does not even see the modifier keys until they have actually modified a key. In other words, you can't bind a raw Ctrl to anything in Emacs, because the OS does not even notify Emacs that Ctrl has been pressed.

To understand part of the reason for this, look at the difference between pressing z and pressing Ctrl+z. The first one sends the ascii code 122, while the second one sends ascii code 26. Note that it does not send two codes in the second case, rather the Ctrl key modified what was sent when pressing z.

One potential workaround to your problem is to create a "sticky" modifier key. This will work much like the ESC key does now. If you press ESC followed by z, Emacs will interpret it as M-z. The code below turns C-] into a "sticky" super key, so that pressing Ctrl+] followed by z will be interpreted as s-z (also known as Super+z):

;; Turn `C-]' into a sticky "super" modifier.
(define-key local-function-key-map [?\C-\]] 'event-apply-super-modifier)
;; Move the global binding for C-] to C-s-]
(define-key global-map [?\C-\s-\]] (lookup-key global-map [?\C-\]] t))
(define-key global-map [?\C-\]] nil)

(It turns out that such a binding to event-apply-super-modifier already exists using C-x @ s. You can try that out to get a feel for how a sticky super modifier might behave.)

Finally, you could make CapsLock work as a sticky "super" key by defining it at the Operating System level (with Seil and Karabiner in your case), to something that is available for binding by Emacs. For example, <pause> or <Scroll_Lock>

  • Thank your for your detailed answer. That it would be complicate, I was aware of as I tried it. :-) I will experiment later on this setting. Actually, I switched my keyboard to US layout and look, if this will be more useful in general. May 2, 2016 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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