我正在研究自己的自定义键盘布局,其中一部分是交换 Caps Lock 和 Esc 键。布局似乎运行良好,所有其他键似乎都已正确重新映射,但当我按下键盘上的物理 Caps Lock 键时,它会按预期激活 Esc。但同时也会切换 Caps Lock。
按下物理 Escape 只会激活 Caps Lock。我希望我可以让物理 Caps Lock 键只激活 Escape。
我尝试使用不同的键盘来查看这是否是我的笔记本电脑的怪癖,问题仍然存在,同时按下 xev 中的 Caps Lock 也出现了这种情况:
KeyPress event, serial 34, synthetic NO, window 0x1800001,
root 0x236, subw 0x0, time 680957, (77,65), root:(299,279),
state 0x2000, keycode 66 (keysym 0xff1b, Escape), same_screen YES,
XKeysymToKeycode returns keycode: 9
XLookupString gives 1 bytes: (1b) "
mbLookupString gives 1 bytes: (1b) "
FilterEvent returns: False
这是我在 /usr/share/X11/xkb/symbols 中的文件
// based on a keyboard map from an 'xkb/symbols/de' file
default
xkb_symbols "basic" {
include "latin(type4)"
name[Group1]="Coding";
// Escape
key <ESC> {[Caps_Lock]};
// Function keys
key <FK01> {[F1]};
key <FK02> {[F2]};
key <FK03> {[F3]};
key <FK04> {[F4]};
key <FK05> {[F5]};
key <FK06> {[F6]};
key <FK07> {[F7]};
key <FK08> {[F8]};
key <FK09> {[F9]};
key <FK10> {[F10]};
key <FK11> {[F11]};
key <FK12> {[F12]};
// First row (numbers/symbols)
key <TLDE> {[bar, ampersand]};
key <AE01> {[exclam, 1]};
key <AE02> {[numbersign, 2]};
key <AE03> {[plus, 3]};
key <AE04> {[minus, 4]};
key <AE05> {[underscore, 5]};
key <AE06> {[equal, 6]};
key <AE07> {[parenleft, 7]};
key <AE08> {[braceleft, 8]};
key <AE09> {[bracketleft, 9]};
key <AE10> {[less, 0]};
key <AE11> {[parenright, braceright]};
key <AE12> {[bracketright, greater]};
key <BKSP> {[BackSpace]};
// Second row
key <TAB> {[grave, question]};
key <AD01> {[v, V]};
key <AD02> {[k, K]};
key <AD03> {[y, Y]};
key <AD04> {[Tab]};
key <AD05> {[f, F]};
key <AD06> {[g, G]};
key <AD07> {[period, comma]};
key <AD08> {[b, B]};
key <AD09> {[o, O]};
key <AD10> {[apostrophe, quotedbl]};
key <AD11> {[percent, asterisk]};
key <AD12> {[asciitilde, at]};
// Third Row
key <CAPS> {[Escape]};
key <AC01> {[r, R]};
key <AC02> {[n, N]};
key <AC03> {[i, I]};
key <AC04> {[e, E]};
key <AC05> {[u, U]};
key <AC06> {[l, L]};
key <AC07> {[t, T]};
key <AC08> {[a, A]};
key <AC09> {[o, O]};
key <AC10> {[s, S]};
key <AC11> {[colon, semicolon]};
key <RTRN> {[Return]};
// Fourth row
key <LFSH> {[Shift_L]};
key <AB01> {[z, Z]};
key <AB02> {[w, W]};
key <AB03> {[c, C]};
key <AB04> {[h, H]};
key <AB05> {[d, D]};
key <AB06> {[m, M]};
key <AB07> {[p, P]};
key <AB08> {[x, X]};
key <AB09> {[j, J]};
key <AB10> {[backslash, slash]};
key <RTSH> {[Shift_R]};
include "kpdl(comma)"
include "level3(ralt_switch)"
};
我该如何解决这个问题?我需要让它在 Wayland 上工作。它确实可以工作,但我怀疑任何 xmodmap 解决方案都行不通。感谢您的帮助。
答案1
有一个 XKB 选项可以实现这一点。例如,您可以在文件中设置它/etc/default/keyboard
:
XKBOPTIONS="caps:swapescape"
因此我建议您尝试一下并将相关部分放入符号文件中。