When defining keybindings in Emacs, it is generally easiest to lookup their 'string representations' pressing C-h k
followed by pressing the key chords you would like to bind.1 You will see the 'string representation' in the beginning of the help window. Subsequently, you can simply wrap it with kbd
and use it in define-key
or global-set-key
etc. as follows:
(global-set-key (kbd "S-<escape>") #'window-toggle-side-windows)
For some reason, even when knowing about this, this information is still not straightforward to find on the web or within the Emacs documentation. Therefore, I am repeating this answer here.
From Emacs version >= 29, one can use keymap-set
in which wrapping the string representation with kbd
is not required anymore.
1. As ESC
is a prefix key by default, using C-h k
does not work directly here. In that case you could try pressing M-: (read-key "Press key (chord): ")
followed by the key (chord), to obtain the string representation.