让修饰键作为X下的切换

有没有办法让ShiftCtrlAlt键表现为X下的切换? 我知道如何在CLI下完成它(例如,通过这样做),但在X下没有找到这样做的参考。

请注意,这不是关于粘滞键的问题,可以通过辅助function选项启用。

这是在DE级AFAIK上实现的。 KDE可以选择锁定粘滞键:

启用锁定粘滞键:

如果按两次Shift键然后按F键,计算机会将其解释为Shift + F. 现在,如果键入P,计算机会将其解释为字母P( Shift + P )。 要取消选择Shift键,请再次按下。

http://docs.kde.org/stable/en/kdebase-workspace/kcontrol/kcmaccess/index.html

使用xmodmap重新映射X11中的键,但/usr/include/X11/keysymdef.h中没有Control_Lock

如果你有几个键,你可以将Control映射到类似ISO_Next_Group_Lock的东西,并使用Control + Key在这个组中定义你的键。

我在这里找到了一些信息: https : //bbs.archlinux.org/viewtopic.php?id = 75771

这可以使用XKB兼容性组件来实现

  1. 检查您正在使用的兼容性变体

    $ setxkbmap -v -query Trying to build keymap using the following components: keycodes: evdev+aliases(qwerty) types: complete compat: complete symbols: pc+us(altgr-intl)+us:2+inet(evdev) geometry: pc(pc105) rules: evdev model: pc105 layout: us,us variant: altgr-intl, $ more /usr/share/X11/xkb/compat/complete default xkb_compatibility "complete" { include "basic" augment "iso9995" augment "mousekeys" augment "accessx(full)" augment "misc" augment "xfree86" augment "level5" augment "caps(caps_lock)" }; 
  2. 修改misc文件,包含所需修饰符解释的文件

     sudo nano /usr/share/X11/xkb/compat/misc 

    我已将Shift_LAlt_LAlt_R操作从SetModsLockMods ,使用LockMods添加了新的Shift_RControl_LControl_R解释,并注释了//setMods.clearLocks (不确定是否需要)。 这是完整的文件:

     default partial xkb_compatibility "misc" { virtual_modifiers Alt,Meta,Super,Hyper,ScrollLock; // Interpretations for some other useful keys interpret Terminate_Server { action = Terminate(); }; //setMods.clearLocks= True; // Sets the "Alt" virtual modifier interpret Alt_L+Any { //useModMapMods= level1; virtualModifier= Alt; action = LockMods(modifiers=modMapMods); }; interpret Alt_L { action = LockMods(modifiers=Alt); }; interpret Alt_R+Any { //useModMapMods= level1; virtualModifier= Alt; action = LockMods(modifiers=modMapMods); }; interpret Alt_R { action = LockMods(modifiers=Alt); }; // Sets the "Meta" virtual modifier interpret Meta_L+Any { // useModMapMods= level1; virtualModifier= Meta; action = SetMods(modifiers=modMapMods); }; interpret Meta_L { action = SetMods(modifiers=Meta); }; interpret Meta_R+Any { //useModMapMods= level1; virtualModifier= Meta; action = SetMods(modifiers=modMapMods); }; interpret Meta_R { action = SetMods(modifiers=Meta); }; // Sets the "Super" virtual modifier interpret Super_L+Any { // useModMapMods= level1; virtualModifier= Super; action = SetMods(modifiers=modMapMods); }; interpret Super_L { action = SetMods(modifiers=Super); }; interpret Super_R+Any { //useModMapMods= level1; virtualModifier= Super; action = SetMods(modifiers=modMapMods); }; interpret Super_R { action = SetMods(modifiers=Super); }; // Sets the "Hyper" virtual modifier interpret Hyper_L+Any { // useModMapMods= level1; virtualModifier= Hyper; action = SetMods(modifiers=modMapMods); }; interpret Hyper_L { action = SetMods(modifiers=Hyper); }; interpret Hyper_R+Any { //useModMapMods= level1; virtualModifier= Hyper; action = SetMods(modifiers=modMapMods); }; interpret Hyper_R { action = SetMods(modifiers=Hyper); }; // Sets the "ScrollLock" virtual modifier and // makes it actually lock when pressed. Sets // up a map for the scroll lock indicator. interpret Scroll_Lock+Any { virtualModifier= ScrollLock; action = LockMods(modifiers=modMapMods); }; include "ledscroll" include "misc(assign_shift_left_action)" }; partial xkb_compatibility "assign_shift_left_action" { // Because of the irrevertable modifier mapping in symbols/pc  is // getting bound to the Lock modifier when using // symbols/shift(both_capslock), creating unwanted behaviour. // This is a quirk, to circumvent the problem. interpret Shift_L { action = LockMods(modifiers = Shift); }; interpret Shift_R { action = LockMods(modifiers = Shift); }; interpret Control_L { action = LockMods(modifiers = Control); }; interpret Control_R { action = LockMods(modifiers = Control); }; }; 
  3. 编译更改并更新initramfs映像

     sudo dpkg-reconfigure xkb-data sudo update-initramfs -u -k all 
  4. 重启

参考文献:

  • Archlinux Wiki:X KeyBoard扩展
  • XKB配置的不可靠指南
  • XKB配置文件