How to prevent the caps-lock toggle effect, without remapping or disabling it

keyboardx11xkbxmodmap

I have an X11 program that grabs caps-lock, and uses it. The problem is, I want to disable the regular caps-lock toggling, but doing so seems to disable the key.

So whatever X11 gets for a caps-lock keypress, it must still get (no disabling the key, or remapping it to some other key), but without anything translating the keypress into a caps-toggle (which might be at the kernel level?).

I tried changing the scancode, but this just remapped the key.
I've removed the capslock entry with xmodmap too, but this also disabled caps.

How can I tell the kernel to ignore the caps-key (wrt its regular functionality), but still pass along the message to X?

Just to add a bit more detail:

The 'program' I'm trying to run is humanised 'enso'.
When there is no key I get the error "CRITICAL:root:Couldn't find quasimode key". When there is no error, I can use enso with caps, but sofar haven't figured out how to disable caps functionality while enso is still able to get at it.

Best Answer

I think I have a technique for disabling the toggling of the Capslock key but not completely disabling the key all together, or remapping it to another key on the keyboard.

If you use the command:

setxkbmap -option caps:none

The keyboard will no longer toggle. I've confirmed this on my laptop running Fedora 14, the LED no longer lights up, and normal Capslock functionality is gone.

However using xev still shows that the key is being pressed:

$ xev
...
...
KeyPress event, serial 35, synthetic NO, window 0x6800001,
    root 0xb1, subw 0x0, time 261504852, (167,-15), root:(353,268),
    state 0x10, keycode 66 (keysym 0xffffff, VoidSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x6800001,
    root 0xb1, subw 0x0, time 261504971, (167,-15), root:(353,268),
    state 0x10, keycode 66 (keysym 0xffffff, VoidSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False
    ...

So the key being pressed events are still left intact for other applications to pick them up.

setxkbmap

The file /usr/share/X11/xkb/rules/xorg.lst contains the complete list of what options you can give to setxkbmap.

Grepping through this file for "cap" I noticed this line:

caps:none            CapsLock is disabled

There are other values in this file so if this isn't what you're after perhaps one of those alternate values would suite instead.

$ grep cap /usr/share/X11/xkb/rules/xorg.lst
  grp:caps_switch      CapsLock (while pressed), Alt+CapsLock does the original capslock action
  grp:caps_toggle      CapsLock
  grp:shift_caps_toggle Shift+CapsLock
  grp:shift_caps_switch CapsLock (to first layout), Shift+CapsLock (to last layout)
  grp:alt_caps_toggle  Alt+CapsLock
  lv3:caps_switch      CapsLock
  lv3:caps_switch_latch CapsLock (chooses 3rd level, latches when pressed together with another 3rd-level-chooser)
  ctrl:nocaps          Make CapsLock an additional Ctrl
  ctrl:swapcaps        Swap Ctrl and CapsLock
  grp_led:caps         CapsLock
  caps                 CapsLock key behavior
  caps:internal        CapsLock uses internal capitalization. Shift "pauses" CapsLock
  caps:internal_nocancel CapsLock uses internal capitalization. Shift doesn't affect CapsLock
  caps:shift           CapsLock acts as Shift with locking. Shift "pauses" CapsLock
  caps:shift_nocancel  CapsLock acts as Shift with locking. Shift doesn't affect CapsLock
  caps:capslock        CapsLock toggles normal capitalization of alphabetic characters
  caps:numlock         Make CapsLock an additional NumLock
  caps:swapescape      Swap ESC and CapsLock
  caps:escape          Make CapsLock an additional ESC
  caps:backspace       Make CapsLock an additional Backspace
  caps:super           Make CapsLock an additional Super
  caps:hyper           Make CapsLock an additional Hyper
  caps:shiftlock       CapsLock toggles Shift so all keys are affected
  caps:none            CapsLock is disabled
  compose:caps         CapsLock
  shift:breaks_caps    Shift cancels CapsLock
  shift:both_capslock  Both Shift-Keys together toggle CapsLock
  shift:both_capslock_cancel Both Shift-Keys together activate CapsLock, one Shift-Key deactivates

References

Related Question