I'm trying to add some functionality to someone else's package, and so I'd like to respect their patterns. Unfortunately, one of these patterns is to not use kbd.

I need to bind a function to C-S-b, but I can't figure out how. I know how to do this with a single modifier (e.g. "\S-b"), but I can't get it to work with multiple modifiers. I know I can just evaluate (kbd "C-S-b") and use its output ([33554434]), but I'd like something easier to read.

Here are a few things I've tried:

(define-key emacs-lisp-mode-map
  "\C-\S-b" 'test-command)
;;; Invalid modifier

(define-key emacs-lisp-mode-map
  [C-S-b] 'test-command)
;;; Does nothing

(define-key emacs-lisp-mode-map
  "\C-B" 'test-command)
;;; Binds C-b

1 Answer 1


You are missing a ? and two backslashes in the vector representation:

(global-set-key [?\C-\S-b] 'test-command)

The section on Key Sequences in the Elisp manual says:

Key sequences containing function keys, mouse button events, system events, or non-ASCII characters such as C-= or H-a cannot be represented as strings; they have to be represented as vectors.

In the vector representation, each element of the vector represents an input event, in its Lisp form. For example, the vector [?\C-x ?l] represents the key sequence C-x l.

And under Other Character Modifier Bits it says:

The Lisp syntax for the shift bit is \S-; thus, ?\C-\S-o or ?\C-\S-O represents the shifted-control-o character.


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.