Shift+Alt+Key shortcuts

I’m used to Shift+Alt+Up/Down shortcuts for line copy in vscode, I want to use them in linux as well. However, they work on windows because keyboard layout swap bind works on button release, not button press, which is not the case for manjaro KDE. How can I change it and use Shift+Alt shortcuts?

What’s that?

I use Shift+Alt+Up and Shift+Alt+Down for multiline edit in sublime text without issue, but perhaps these line copy shortcuts you speak of are a type of shortcut I’m not used to.

I’ve never used vscode so I’m not sure exactly how they work, or are meant to work. Maybe a more thorough explanation of expected and actual behaviour would help.

AFAIK this behaviour is hardcoded, so it’s up to the relevant devs to make it work on key release. You’re by no means the first to want it changed, but I doubt it will happen anytime soon.

You’ve said this is the problem, but not why it’s the problem. How does it get in the way of the shortcuts?

1 Like

Ctrl+L and Ctrl+C copies a line in VSCode. Ctrl+L expands whatever selection we have to the line.

Ctrl+Shift+Alt+ <arrow> duplicates/copies the current line above or below.

It’s confusing to mix up language like this, like typing 'Shift+Alt` instead of the convention where Ctrl>Alt>Shift are in reversed order…

Buttons and Keys are also very different things - we use ‘button’ with mouse buttons, and ‘keys’ with keyboard keys… but I am not sure why swapping keyboard layouts is relevant to copying a line of text.

1 Like

Sorry for confusing language, I meant “Copy Line Down / Up” shortucts, as vscode calls them.My problem is that I can’t use shortcuts that include Alt+Shift:

  • When I’m trying to change any shortcut in vscode with its GUI, it accepts shift+alt shortcut, but if I hold shift+alt and press any other key, it overwrites the last pressed key, so I get, for example, shift/alt+up instead of alt+shift+up. Also vscode provides ctrl+shift+alt+up/down shortcuts for copy line up/down by default, but they don’t work. For example, when I press ctrl+shift+alt+down (in that order), I do whatever is set to ctrl+shift+down (add cursors below by default)

  • I can set alt+shift+key shortcuts in sublime text with its config file, but they don’t work. The default shortcuts that include alt+shift don’t work either

  • I also tried to set alt+shift+key shortcuts in dolphin through its GUI, but it doesn’t read the second key pressed in alt+shift

That’s not normal and seems to have nothing to do with it working on key press/release.

Perhaps either Shift or Alt are being used for something else and that’s interfering. Please post the output from this command.

setxkbmap -print -verbose 10
1 Like
Setting verbose level to 10
WARNING: Running setxkbmap against an Xwayland server
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc105
layout:     us
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+us+inet(evdev)
geometry:   pc(pc105)
xkb_keymap {
        xkb_keycodes  { include "evdev+aliases(qwerty)" };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_symbols   { include "pc+us+inet(evdev)"     };
        xkb_geometry  { include "pc(pc105)"     };
};

According to that there shouldn’t be any config getting in the way, but it’s wayland and I haven’t used it much, just a little testing, so I can’t be sure. Best to check your plasma config too. System Settings → Input Devices → Keyboard

Have you tried using X11?

Yes, X11 has the same issue

Could you run that command again in X11 please? AFAIK it should work in either for this use case, but I’m not sure it can always be trusted in wayland. ¹

Have you used evtest or xev -event keyboard to check exactly what’s being received? I imagine it’s what we expect, but you never know.

Do you have any input remap utilities set up?
Have you done anything to the system regarding the keyboard or other input devices?
Changed keymap, installed something etc?

EDIT:

¹ I’m sure I’ve recently seen it report the correct info in wayland, but it seems to consistently report a default US map now. Perhaps I was hallucinating.

Output in X11:

Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc104
layout:     us,ru
options:    grp:alt_shift_toggle
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+us+ru:2+inet(evdev)+group(alt_shift_toggle)
geometry:   pc(pc104)
xkb_keymap {
        xkb_keycodes  { include "evdev+aliases(qwerty)" };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_symbols   { include "pc+us+ru:2+inet(evdev)+group(alt_shift_toggle)"        };
        xkb_geometry  { include "pc(pc104)"     };
};

evtest result after pressing shift, alt and up (in this order) and releasing them:

Testing ... (interrupt to exit)
Event: time 1694695340.798363, type 4 (EV_MSC), code 4 (MSC_SCAN), value 03
Event: time 1694695340.798363, type 1 (EV_KEY), code 3 (KEY_2), value 0
Event: time 1694695340.798363, -------------- SYN_REPORT ------------
Event: time 1694695340.835217, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1c
Event: time 1694695340.835217, type 1 (EV_KEY), code 28 (KEY_ENTER), value 0
Event: time 1694695340.835217, -------------- SYN_REPORT ------------
Event: time 1694695342.322843, type 4 (EV_MSC), code 4 (MSC_SCAN), value 2a
Event: time 1694695342.322843, type 1 (EV_KEY), code 42 (KEY_LEFTSHIFT), value 1
Event: time 1694695342.322843, -------------- SYN_REPORT ------------
Event: time 1694695342.408311, type 4 (EV_MSC), code 4 (MSC_SCAN), value 38
Event: time 1694695342.408311, type 1 (EV_KEY), code 56 (KEY_LEFTALT), value 1
Event: time 1694695342.408311, -------------- SYN_REPORT ------------
Event: time 1694695342.550549, type 4 (EV_MSC), code 4 (MSC_SCAN), value c8
Event: time 1694695342.550549, type 1 (EV_KEY), code 103 (KEY_UP), value 1
Event: time 1694695342.550549, -------------- SYN_REPORT ------------
Event: time 1694695342.648520, type 4 (EV_MSC), code 4 (MSC_SCAN), value 2a
Event: time 1694695342.648520, type 1 (EV_KEY), code 42 (KEY_LEFTSHIFT), value 0
Event: time 1694695342.648520, -------------- SYN_REPORT ------------
Event: time 1694695342.700378, type 4 (EV_MSC), code 4 (MSC_SCAN), value c8
Event: time 1694695342.700378, type 1 (EV_KEY), code 103 (KEY_UP), value 0
Event: time 1694695342.700378, -------------- SYN_REPORT ------------
Event: time 1694695342.708507, type 4 (EV_MSC), code 4 (MSC_SCAN), value 38
Event: time 1694695342.708507, type 1 (EV_KEY), code 56 (KEY_LEFTALT), value 0
Event: time 1694695342.708507, -------------- SYN_REPORT ------------
Event: time 1694695345.586816, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1d
Event: time 1694695345.586816, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 1
Event: time 1694695345.586816, -------------- SYN_REPORT ------------
Event: time 1694695345.629766, type 4 (EV_MSC), code 4 (MSC_SCAN), value 2e
Event: time 1694695345.629766, type 1 (EV_KEY), code 46 (KEY_C), value 1
Event: time 1694695345.629766, -------------- SYN_REPORT ------------
^C

xev -event keyboard result after pressing shift+alt+up, shift+alt and alt+shift (in these orders):

Outer window is 0x3e00001, inner window is 0x3e00002

KeymapNotify event, serial 24, synthetic NO, window 0x0,
    keys:  153 0   0   0   16  0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

KeyRelease event, serial 25, synthetic NO, window 0x3e00001,
    root 0x6b8, subw 0x0, time 669560, (636,263), root:(1827,1010),
    state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
"   XLookupString gives 1 bytes: (0d) "
    XFilterEvent returns: False

KeyPress event, serial 28, synthetic NO, window 0x3e00001,
    root 0x6b8, subw 0x0, time 673444, (636,263), root:(1827,1010),
    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 0x3e00001,
    root 0x6b8, subw 0x0, time 673520, (636,263), root:(1827,1010),
    state 0x1, keycode 64 (keysym 0xfe08, ISO_Next_Group), same_screen YES,
    XKeysymToKeycode returns keycode: 50
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 28, synthetic NO, window 0x3e00001,
    root 0x6b8, subw 0x0, time 673625, (636,263), root:(1827,1010),
    state 0x2001, keycode 111 (keysym 0xff52, Up), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x3e00001,
    root 0x6b8, subw 0x0, time 673773, (636,263), root:(1827,1010),
    state 0x2001, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x3e00001,
    root 0x6b8, subw 0x0, time 673786, (636,263), root:(1827,1010),
    state 0x2000, keycode 111 (keysym 0xff52, Up), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x3e00001,
    root 0x6b8, subw 0x0, time 673795, (636,263), root:(1827,1010),
    state 0x2000, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 28, synthetic NO, window 0x3e00001,
    root 0x6b8, subw 0x0, time 675173, (636,263), root:(1827,1010),
    state 0x2000, 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 0x3e00001,
    root 0x6b8, subw 0x0, time 675236, (636,263), root:(1827,1010),
    state 0x2001, keycode 64 (keysym 0xfe08, ISO_Next_Group), same_screen YES,
    XKeysymToKeycode returns keycode: 50
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x3e00001,
    root 0x6b8, subw 0x0, time 675394, (636,263), root:(1827,1010),
    state 0x1, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x3e00001,
    root 0x6b8, subw 0x0, time 675423, (636,263), root:(1827,1010),
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 28, synthetic NO, window 0x3e00001,
    root 0x6b8, subw 0x0, time 675824, (636,263), root:(1827,1010),
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 28, synthetic NO, window 0x3e00001,
    root 0x6b8, subw 0x0, time 675866, (636,263), root:(1827,1010),
    state 0x8, keycode 50 (keysym 0xfe08, ISO_Next_Group), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x3e00001,
    root 0x6b8, subw 0x0, time 675974, (636,263), root:(1827,1010),
    state 0x2008, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x3e00001,
    root 0x6b8, subw 0x0, time 676056, (636,263), root:(1827,1010),
    state 0x2000, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

ClientMessage event, serial 28, synthetic YES, window 0x3e00001,
    message_type 0x156 (WM_PROTOCOLS), format 32, message 0x157 (WM_DELETE_WINDOW)

It seems that xev catches KeyPress event with ISO_Next_Group code instead of an actual key when I already hold Shift or Alt, but I don’t know if its a correct behavior or not
I haven’t installed any input remap utilities except gestures GUI for libinput-gestures. I have changed some default bindings in settings, but nothing related to keyboard layout. Also, I haven’t found any of the listed utilities on my system. If it matters, I tried to build electron20 from AUR, it was a dependency for another package and this version was not available anywhere else, but it failed so it shouldn’t have affected anything

It’s the group(alt_shift_toggle) option that’s messing things up.

System Settings → Input Devices → Keyboard → Advanced → Switching to another layout

Change it to something that doesn’t use Alt and/or Shift (aka Left Alt and Left Shift).

It’s correct when the option above is set to Alt + Shift or Left Alt + Left Shift.

Uhh, of course I can remove or change layout switch binding and use it in vscode, but is there a way to keep both?
UPD. I’ve found this repo that seems to do what I want, but its not supported, its not in an package manager and I’m not sure about using random package from the internet, is there anything similar in pamac or aur? GitHub - Dragiyski/alt-shift-toggle: Allow proper keyboard layout switch with Alt+Shift in linux

Not that I know of.