TransWikia.com

Keybindings with Shift key does not work when CAPS is on

Emacs Asked by Tian on September 2, 2021

I have this mnemonic keybinding which I placed in my config

;; Switching window backwards
(global-set-key (kbd "C-x O") (lambda ()
                                (interactive)
                                (other-window -1)))

Which works fine, but works in the opposite direction when my CAPS are on.
I have tried

;; Switching window backwards
(global-set-key (kbd "C-x S-o") (lambda ()
                                (interactive)
                                (other-window -1)))

but this does not work at all, it just gives me the regular forward buffer

One Answer

The comments clarified that the question was about the behaviour of holding down the Shift modifier key while Caps Lock was on.

It's common for the shift key to invert the state of caps lock, rather than to unconditionally enable caps. Hence:

  1. t => t
  2. SHIFT + t => T
  3. CAPS + t => T
  4. CAPS + SHIFT + t => t

In that latter case, Emacs sees only a lower-case t. It is not aware that the shift key and the caps lock key were both involved in producing it, so you cannot make case (4) behave differently to case (1).

To prevent this, I think you'll need to look for some kind of "do not allow shift to invert an active caps lock" option in your OS or window manager.

Answered by phils on September 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP