Is there a function that maps a keyboard input character to the character that would have been input if the shift key modifier was being pressed? For instance if I pass the input ?c it would return ?C, or if I pass the input ?2 it would return ?@.

  • 1
    Spontaneously, I don't think so since Emacs has no direct knowledge about keymaps. Hence, it can't know if shift 2 would be @ (as used in the US) or " (which is used on some european layouts). Commented Jun 1, 2022 at 18:37
  • Sticky Keys might be helpful for you. It's a feature of your operating system and/or keyboard, not Emacs.
    – Tyler
    Commented Jun 1, 2022 at 18:59
  • If the goal is, for example, to bind a command to “Ctrl+Shift+2” in a way that's independent of the keyboard layout, I don't think Emacs provides a way to do this. Emacs's key binding philosophy is to be independent of the keyboard layout, for example up/down/left/right are P[revious]/N[ext]/B[ackward]/F[orward] and not WASD or ijkl. I don't think there's any code in Emacs to query the “base key” information when parsing an event from the operating system. Commented Jun 1, 2022 at 19:04

1 Answer 1


You can probably do it with the function event-apply-shift-modifier. But it will depend on exactly what you're using it for (of course).

  • 1
    event-apply-shift-modifier reads an event, it doesn't take an event or a character as argument. You'd need to call event-apply-modifier directly. But that wouldn't do what the asker wants: it uppercases ASCII letters, but you can easily do that manually anyway. Other characters (non-ASCII letters, non-letters) are mapped to events with the shift bit set, not to a different base character. Commented Jun 1, 2022 at 18:59

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.