Closed yyy33 closed 2 years ago
When I press ctrl-enter, I get the following keystroke event(Captured by xev). [...]
In the future please post the output of keyd -m
, it is much more concise. It would also help if you could only post the relevant portion of the config.
As you can see, keyd sends 4 additional control_l and 2 shift_l
To summarize, the problematic portion of your config is equivalent to:
[customControl:C]
enter = macro(esc [18;6~)
and the output is:
Control_L down
Control_L up
Escape down
Escape up
bracketleft down
bracketleft up
1 down
1 up
8 down
8 up
semicolon down
semicolon up
6 down
6 up
Shift_L down
asciitilde down
asciitilde up
Shift_L up
Control_L down
Control_L up
The output is precisely what you should expect. I'm not sure what the 'additional shift' you're referring to is. Your macro contains ~
which necessarily produces the only shift key in the output. The control down/up events are present because you have bound the macro within a control layer, they should not affect the output.
I think part of your problem might stem from some misapprehensions about terminal input. ANSI sequences need to be written to the TTY. Input from your keyboard is generated by your terminal emulator as output from the TTY. You can't directly input special characters from your keyboard and expect the terminal to act on them. If you want an escaped statement suitable for use in things like printf
then you probably want something like macro(\\033[31m)
instead.
When I press ctrl-enter, I get the following keystroke event(Captured by xev). [...]
In the future please post the output of
keyd -m
, it is much more concise. It would also help if you could only post the relevant portion of the config.As you can see, keyd sends 4 additional control_l and 2 shift_l
To summarize, the problematic portion of your config is equivalent to:
[customControl:C] enter = macro(esc [18;6~)
and the output is:
Control_L down Control_L up Escape down Escape up bracketleft down bracketleft up 1 down 1 up 8 down 8 up semicolon down semicolon up 6 down 6 up Shift_L down asciitilde down asciitilde up Shift_L up Control_L down Control_L up
The output is precisely what you should expect. I'm not sure what the 'additional shift' you're referring to is. Your macro contains
~
which necessarily produces the only shift key in the output. The control down/up events are present because you have bound the macro within a control layer, they should not affect the output.I think part of your problem might stem from some misapprehensions about terminal input. ANSI sequences need to be written to the TTY. Input from your keyboard is generated by your terminal emulator as output from the TTY. You can't directly input special characters from your keyboard and expect the terminal to act on them. If you want an escaped statement suitable for use in things like
printf
then you probably want something likemacro(\\033[31m)
instead.
[main]
leftshift = layer(leftshift{alacritty})
[leftshift{alacritty}:S] enter = macro(esc [17;5~)
2. When I press `shift-enter`, the event I detect is this, but I think the first line of `leftshift up` and the second line of `leftshift down` should not exist
leftshift down
leftshift up
esc down
esc up
[ down
[ up
1 down
1 up
7 down
7 up
; down
; up
5 down
5 up
leftshift down
down
up
leftshift up
:S
makes leftshift{alacritty}
(incidentally you really should be using keyd-application-mapper
) behave like shift
. This means as soon as you press it shift down
is emitted. It is a feature (not a bug). It should not have any effect on what you are trying to achieve in this instance.
I am using fcitx
input method and bound shift
to activate/disable it, the first and second events are detected by fcitx, so it is always activated or disabled every time I press shift-enter
.
I think I may do some configuration in awesome wm
, use different layout for different application by keyd ipc
, not that keyd-application-mapper
is bad, I just want to run as few things as possible, my computer performance is relatively low
:S
makesleftshift{alacritty}
(incidentally you really should be usingkeyd-application-mapper
) behave likeshift
. This means as soon as you press itshift down
is emitted. It is a feature (not a bug). It should not have any effect on what you are trying to achieve in this instance.
[capslock{alacritty}+alt]
h = macro(esc [1;3S)
capslock+alt+h
, I get the following event,which esc [1;3S
become esc [1;4R
,And there are two more events leftalt down
and leftalt up
leftalt down
esc down
esc up
[ down
[ up
1 down
1 up
; down
; up
4 down
4 up
leftshift down
r down
r up
leftshift up
leftalt up
I am using fcitx input method and bound shift to activate/disable it, the first and second events are detected by fcitx, so it is always activated or disabled every time I press shift-enter.
Then there is an inherent conflict in your bindings. You either want to avoid :S
or (better) remap your fcitx key and then use overload within keyd to remap your left shift key to produce it on tap.
I think I may do some configuration in awesome wm, use different layout for different application by keyd ipc, not that keyd-application-mapper is bad, I just want to run as few things as possible, my computer performance is relatively low
Unless you are trying to avoid installing python, you are better off using the shipped option. The script is interrupt driven and spends most of its time waiting for X events (like awesome), using the awesome's IPC functionality doesn't avoid this (it just adds another socket between you and the X server).
When I press capslock+alt+h, I get the following event,which esc [1;3S
That is the expected output given your config. Please reread the man page (hint: you've rebound leftalt).
I am going to close this for now, since it involves several different issues and is not a bug.
I am using fcitx input method and bound shift to activate/disable it, the first and second events are detected by fcitx, so it is always activated or disabled every time I press shift-enter.
Then there is an inherent conflict in your bindings. You either want to avoid
:S
or (better) remap your fcitx key and then use overload within keyd to remap your left shift key to produce it on tap.I think I may do some configuration in awesome wm, use different layout for different application by keyd ipc, not that keyd-application-mapper is bad, I just want to run as few things as possible, my computer performance is relatively low
Unless you are trying to avoid installing python, you are better off using the shipped option. The script is interrupt driven and spends most of its time waiting for X events (like awesome), using the awesome's IPC functionality doesn't avoid this (it just adds another socket between you and the X server).
When I press capslock+alt+h, I get the following event,which esc [1;3S
That is the expected output given your config. Please reread the man page (hint: you've rebound leftalt).
I am going to close this for now, since it involves several different issues and is not a bug.
Thank you for your help and I will try your suggestions
ctrl-enter
, I get the following keystroke event(Captured byxev
). As you can see,keyd
sends 4 additionalcontrol_l
and 2shift_l
KeyPress event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593701, (636,176), root:(637,229), state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES, XLookupString gives 0 bytes: XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x0, keycode 9 (keysym 0xff1b, Escape), same_screen YES, XLookupString gives 1 bytes: (1b) " mbLookupString gives 1 bytes: (1b) " FilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x0, keycode 9 (keysym 0xff1b, Escape), same_screen YES, XLookupString gives 1 bytes: (1b) " FilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x0, keycode 34 (keysym 0x5b, bracketleft), same_screen YES, XLookupString gives 1 bytes: (5b) "[" XmbLookupString gives 1 bytes: (5b) "[" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x0, keycode 34 (keysym 0x5b, bracketleft), same_screen YES, XLookupString gives 1 bytes: (5b) "[" XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x0, keycode 10 (keysym 0x31, 1), same_screen YES, XLookupString gives 1 bytes: (31) "1" XmbLookupString gives 1 bytes: (31) "1" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x0, keycode 10 (keysym 0x31, 1), same_screen YES, XLookupString gives 1 bytes: (31) "1" XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x0, keycode 17 (keysym 0x38, 8), same_screen YES, XLookupString gives 1 bytes: (38) "8" XmbLookupString gives 1 bytes: (38) "8" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x0, keycode 17 (keysym 0x38, 8), same_screen YES, XLookupString gives 1 bytes: (38) "8" XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x0, keycode 47 (keysym 0x3b, semicolon), same_screen YES, XLookupString gives 1 bytes: (3b) ";" XmbLookupString gives 1 bytes: (3b) ";" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x0, keycode 47 (keysym 0x3b, semicolon), same_screen YES, XLookupString gives 1 bytes: (3b) ";" XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x0, keycode 15 (keysym 0x36, 6), same_screen YES, XLookupString gives 1 bytes: (36) "6" XmbLookupString gives 1 bytes: (36) "6" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x0, keycode 15 (keysym 0x36, 6), same_screen YES, XLookupString gives 1 bytes: (36) "6" XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), 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 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x1, keycode 49 (keysym 0x7e, asciitilde), same_screen YES, XLookupString gives 1 bytes: (7e) "~" XmbLookupString gives 1 bytes: (7e) "~" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x1, keycode 49 (keysym 0x7e, asciitilde), same_screen YES, XLookupString gives 1 bytes: (7e) "~" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x1, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES, XLookupString gives 0 bytes: XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 593789, (636,176), root:(637,229), state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1c00001, root 0x579, subw 0x0, time 594021, (636,176), root:(637,229), state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES, XLookupString gives 0 bytes: XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1722927, (748,201), root:(749,254), state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1722967, (748,201), root:(749,254), state 0x4, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723007, (748,201), root:(749,254), state 0x5, keycode 37 (keysym 0xffe3, Control_L), same_screen YES, XLookupString gives 0 bytes: XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723007, (748,201), root:(749,254), state 0x1, keycode 9 (keysym 0xff1b, Escape), same_screen YES, XLookupString gives 1 bytes: (1b) " mbLookupString gives 1 bytes: (1b) " FilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723007, (748,201), root:(749,254), state 0x1, keycode 9 (keysym 0xff1b, Escape), same_screen YES, XLookupString gives 1 bytes: (1b) " FilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723007, (748,201), root:(749,254), state 0x1, keycode 34 (keysym 0x7b, braceleft), same_screen YES, XLookupString gives 1 bytes: (7b) "{" XmbLookupString gives 1 bytes: (7b) "{" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723007, (748,201), root:(749,254), state 0x1, keycode 34 (keysym 0x7b, braceleft), same_screen YES, XLookupString gives 1 bytes: (7b) "{" XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723007, (748,201), root:(749,254), state 0x1, keycode 11 (keysym 0x40, at), same_screen YES, XLookupString gives 1 bytes: (40) "@" XmbLookupString gives 1 bytes: (40) "@" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723007, (748,201), root:(749,254), state 0x1, keycode 11 (keysym 0x40, at), same_screen YES, XLookupString gives 1 bytes: (40) "@" XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723007, (748,201), root:(749,254), state 0x1, keycode 19 (keysym 0x29, parenright), same_screen YES, XKeysymToKeycode returns keycode: 188 XLookupString gives 1 bytes: (29) ")" XmbLookupString gives 1 bytes: (29) ")" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723007, (748,201), root:(749,254), state 0x1, keycode 19 (keysym 0x29, parenright), same_screen YES, XKeysymToKeycode returns keycode: 188 XLookupString gives 1 bytes: (29) ")" XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723007, (748,201), root:(749,254), state 0x1, keycode 47 (keysym 0x3a, colon), same_screen YES, XLookupString gives 1 bytes: (3a) ":" XmbLookupString gives 1 bytes: (3a) ":" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723007, (748,201), root:(749,254), state 0x1, keycode 47 (keysym 0x3a, colon), same_screen YES, XLookupString gives 1 bytes: (3a) ":" XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723007, (748,201), root:(749,254), state 0x1, keycode 15 (keysym 0x5e, asciicircum), same_screen YES, XLookupString gives 1 bytes: (5e) "^" XmbLookupString gives 1 bytes: (5e) "^" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723007, (748,201), root:(749,254), state 0x1, keycode 15 (keysym 0x5e, asciicircum), same_screen YES, XLookupString gives 1 bytes: (5e) "^" XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723007, (748,201), root:(749,254), state 0x1, keycode 49 (keysym 0x7e, asciitilde), same_screen YES, XLookupString gives 1 bytes: (7e) "~" XmbLookupString gives 1 bytes: (7e) "~" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723007, (748,201), root:(749,254), state 0x1, keycode 49 (keysym 0x7e, asciitilde), same_screen YES, XLookupString gives 1 bytes: (7e) "~" XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723007, (748,201), root:(749,254), state 0x1, keycode 37 (keysym 0xffe3, Control_L), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723327, (748,201), root:(749,254), state 0x5, keycode 37 (keysym 0xffe3, Control_L), same_screen YES, XLookupString gives 0 bytes: XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 1723327, (748,201), root:(749,254), state 0x1, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES, XLookupString gives 0 bytes: XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310809, (636,176), root:(637,229), state 0x0, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310889, (636,176), root:(637,229), state 0x1, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES, XLookupString gives 0 bytes: XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310889, (636,176), root:(637,229), state 0x0, keycode 9 (keysym 0xff1b, Escape), same_screen YES, XLookupString gives 1 bytes: (1b) " mbLookupString gives 1 bytes: (1b) " FilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310889, (636,176), root:(637,229), state 0x0, keycode 9 (keysym 0xff1b, Escape), same_screen YES, XLookupString gives 1 bytes: (1b) " FilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310889, (636,176), root:(637,229), state 0x0, keycode 34 (keysym 0x5b, bracketleft), same_screen YES, XLookupString gives 1 bytes: (5b) "[" XmbLookupString gives 1 bytes: (5b) "[" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310889, (636,176), root:(637,229), state 0x0, keycode 34 (keysym 0x5b, bracketleft), same_screen YES, XLookupString gives 1 bytes: (5b) "[" XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310889, (636,176), root:(637,229), state 0x0, keycode 10 (keysym 0x31, 1), same_screen YES, XLookupString gives 1 bytes: (31) "1" XmbLookupString gives 1 bytes: (31) "1" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310889, (636,176), root:(637,229), state 0x0, keycode 10 (keysym 0x31, 1), same_screen YES, XLookupString gives 1 bytes: (31) "1" XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310889, (636,176), root:(637,229), state 0x0, keycode 16 (keysym 0x37, 7), same_screen YES, XLookupString gives 1 bytes: (37) "7" XmbLookupString gives 1 bytes: (37) "7" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310889, (636,176), root:(637,229), state 0x0, keycode 16 (keysym 0x37, 7), same_screen YES, XLookupString gives 1 bytes: (37) "7" XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310889, (636,176), root:(637,229), state 0x0, keycode 47 (keysym 0x3b, semicolon), same_screen YES, XLookupString gives 1 bytes: (3b) ";" XmbLookupString gives 1 bytes: (3b) ";" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310889, (636,176), root:(637,229), state 0x0, keycode 47 (keysym 0x3b, semicolon), same_screen YES, XLookupString gives 1 bytes: (3b) ";" XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310889, (636,176), root:(637,229), state 0x0, keycode 14 (keysym 0x35, 5), same_screen YES, XLookupString gives 1 bytes: (35) "5" XmbLookupString gives 1 bytes: (35) "5" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310889, (636,176), root:(637,229), state 0x0, keycode 14 (keysym 0x35, 5), same_screen YES, XLookupString gives 1 bytes: (35) "5" XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310889, (636,176), root:(637,229), 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 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310889, (636,176), root:(637,229), state 0x1, keycode 49 (keysym 0x7e, asciitilde), same_screen YES, XLookupString gives 1 bytes: (7e) "~" XmbLookupString gives 1 bytes: (7e) "~" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 310889, (636,176), root:(637,229), state 0x1, keycode 49 (keysym 0x7e, asciitilde), same_screen YES, XLookupString gives 1 bytes: (7e) "~" XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001, root 0x579, subw 0x0, time 311105, (636,176), root:(637,229), state 0x1, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES, XLookupString gives 0 bytes: XFilterEvent returns: False