I would like to toggle input method in emacs with OS key binding, i.e. ctrl-shift, so it behaves like a normal desktop application. In other words I want to rebind C-\ to just C-S without any extra keys.

My keypoints are:

  1. I am on Linux
  2. I want all key bindings to work regardless of current language, including evil-ones.
  3. Switching languages should be done on key release (C-S-% should not switch language)

I tried to write XKB-interceptor on C, which is listens XkbActionMessages and sends it back to emacs. It works, but due to XKB Bug 865 it switches languages on key press, not release. So it messes with C-S-x key bindings. There is a patch to workaround this bug, but it not covers XkbActionMessages message. Extending that patch is too much for me.

Maybe there is easier way to accomplish my goal?

  • The question is not too clear, for me. Do you mean only Control + Shift or those in combination with some other key(s)? Those are only modifier keys.
    – Drew
    Mar 18, 2016 at 14:33
  • Please clarify what you are trying to do. Note that, if you bind C-S at the OS level such that the OS intercepts the keys before they ever reach Emacs, there's nothing Emacs can do about it.
    – Dan
    Mar 18, 2016 at 14:55
  • I want to make C-S to switch input methods without any other keys. I know I can't do it within emacs itself, it's more like a linux question. Mar 18, 2016 at 15:26
  • 1
    I'm pretty sure this can't be done within Emacs. You'd either have to modify the Emacs source code (the C part, not just the Lisp part) or use a third-party program that intercepts the keyboard action and sends something else to Emacs. We can't help you with that third-party program since it has nothing to do with Emacs. Mar 18, 2016 at 17:22
  • 1
    Regarding that third-party program, if you're coding something, you can ask for help on Stack Overflow. If you're looking for something ready-made, you can ask on Unix & Linux; be sure to mention what window manager or desktop environment you're using as many WM/DE perform their own keyboard interception. Also, what GUI toolkit is Emacs using (if you don't understand the question, what binary are you using, e.g. “the `emacs24-lucid” package from Debian”)? Mar 18, 2016 at 17:22

1 Answer 1


I ended up with this solution on python, which parses xinput and sends a key to emacs window.

  • If this solution meets your needs, please accept your own answer so we can mark the question as closed.
    – Dan
    Mar 26, 2017 at 9:27

Your Answer

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

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