使用 xcape 保留管道字符将反斜杠映射到修饰符

使用 xcape 保留管道字符将反斜杠映射到修饰符

我的键盘有一个反斜杠键,移动时它是一个管道字符。

我想将它在 xorg 中映射到Hyper按住时的修饰符,以及按下时的默认行为。

我已将以下代码添加到我的.xinitrc

xmodmap -e "keycode 23 = Hyper_L"
xmodmap -e "keycode any = backslash"
xcape -e "Hyper_L=backslash"

按照中的示例man xcape

它在按住时充当修饰符,在按下时充当反斜杠,但在按住 Shift 的情况下按下时,仍会发送反斜杠!为什么不用管子呢?

xev反斜杠作为修饰符的输出:

KeyPress event, serial 28, synthetic NO, window 0x1600001,
    root 0x1a5, subw 0x0, time 50265029, (554,460), root:(1426,924),
    state 0x0, keycode 51 (keysym 0xffed, Hyper_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyPress event, serial 28, synthetic NO, window 0x1600001,
    root 0x1a5, subw 0x0, time 50265325, (554,460), root:(1426,924),
    state 0x40, keycode 38 (keysym 0x61, a), same_screen YES,
    XLookupString gives 1 bytes: (61) "a"
    XmbLookupString gives 1 bytes: (61) "a"
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x1600001,
    root 0x1a5, subw 0x0, time 50265481, (554,460), root:(1426,924),
    state 0x40, keycode 38 (keysym 0x61, a), same_screen YES,
    XLookupString gives 1 bytes: (61) "a"
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x1600001,
    root 0x1a5, subw 0x0, time 50265725, (554,460), root:(1426,924),
    state 0x40, keycode 51 (keysym 0xffed, Hyper_L), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

xev反斜杠作为未移位键的输出:

KeyPress event, serial 28, synthetic NO, window 0x2400001,
    root 0x1a5, subw 0x0, time 50512478, (542,233), root:(1414,697),
    state 0x0, keycode 51 (keysym 0xffed, Hyper_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x2400001,
    root 0x1a5, subw 0x0, time 50512598, (542,233), root:(1414,697),
    state 0x40, keycode 51 (keysym 0xffed, Hyper_L), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

MappingNotify event, serial 28, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 28, synthetic NO, window 0x2400001,
    root 0x1a5, subw 0x0, time 50512598, (542,233), root:(1414,697),
    state 0x0, keycode 8 (keysym 0x5c, backslash), same_screen YES,
    XLookupString gives 1 bytes: (5c) "\"
    XmbLookupString gives 1 bytes: (5c) "\"
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x2400001,
    root 0x1a5, subw 0x0, time 50512598, (542,233), root:(1414,697),
    state 0x0, keycode 8 (keysym 0x5c, backslash), same_screen YES,
    XLookupString gives 1 bytes: (5c) "\"
    XFilterEvent returns: False

MappingNotify event, serial 29, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

xev移位反斜杠的输出:

KeyPress event, serial 28, synthetic NO, window 0x1600001,
    root 0x1a5, subw 0x0, time 50591657, (514,-58), root:(1386,406),
    state 0x0, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyPress event, serial 28, synthetic NO, window 0x1600001,
    root 0x1a5, subw 0x0, time 50591965, (514,-58), root:(1386,406),
    state 0x1, keycode 51 (keysym 0xffed, Hyper_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x1600001,
    root 0x1a5, subw 0x0, time 50592077, (514,-58), root:(1386,406),
    state 0x41, keycode 51 (keysym 0xffed, Hyper_L), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

MappingNotify event, serial 28, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 28, synthetic NO, window 0x1600001,
    root 0x1a5, subw 0x0, time 50592077, (514,-58), root:(1386,406),
    state 0x1, keycode 8 (keysym 0x5c, backslash), same_screen YES,
    XLookupString gives 1 bytes: (5c) "\"
    XmbLookupString gives 1 bytes: (5c) "\"
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x1600001,
    root 0x1a5, subw 0x0, time 50592078, (514,-58), root:(1386,406),
    state 0x1, keycode 8 (keysym 0x5c, backslash), same_screen YES,
    XLookupString gives 1 bytes: (5c) "\"
    XFilterEvent returns: False

MappingNotify event, serial 29, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyRelease event, serial 29, synthetic NO, window 0x1600001,
    root 0x1a5, subw 0x0, time 50592201, (514,-58), root:(1386,406),
    state 0x1, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

相关内容