VNC eats keypresses

20220126 - updated - fix detailed at the bottom.

I use i3wm locally and on my remote desktop, and have the move-to-workspace shortcut configured as Shift+Mod4+$number (so Shift+Windows key+[0-9]).

When using my local i3, Shift+Mod4+2 and Shift+Mod4+3 moves the active window to the second or third remote desktop respectively.

When connecting to my remote i3 over VNC (TigerVNC and RealVNC - full keyboard capturing enabled), Shift+Mod4+2 or Shift+Mod4+3 results in " or £ appearing (if it's a terminal window). Shift+Mod4+any-other-number moves the active window to the respective desktop.

Looking at the output of xev locally when pressing Shift, then adding Mod4, finally the 3 key, I see:

KeyPress event, serial 34, synthetic NO, window 0x3a00001,
    root 0x1a3, subw 0x0, time 607474486, (335,52), root:(2899,957),
    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 34, synthetic NO, window 0x3a00001,
    root 0x1a3, subw 0x0, time 607476496, (335,52), root:(2899,957),
    state 0x1, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

FocusOut event, serial 34, synthetic NO, window 0x3a00001,
    mode NotifyGrab, detail NotifyAncestor

However when doing the same over VNC:

KeyPress event, serial 34, synthetic NO, window 0x1a00001,
    root 0x3b5, subw 0x0, time 76399307, (103,837), root:(2027,857),
    state 0x0, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyPress event, serial 34, synthetic NO, window 0x1a00001,
    root 0x3b5, subw 0x0, time 76399901, (103,837), root:(2027,857),
    state 0x40, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyPress event, serial 34, synthetic NO, window 0x1a00001,
    root 0x3b5, subw 0x0, time 76401497, (103,837), root:(2027,857),
    state 0x41, keycode 253 (keysym 0xa3, sterling), same_screen YES,
    XLookupString gives 2 bytes: (c2 a3) "£"
    XmbLookupString gives 2 bytes: (c2 a3) "£"
    XFilterEvent returns: False

So once '3' is pressed, it looks like Mod4 is no longer active.

However, when doing Shift+Mod4+1, xev shows the right events:

KeyPress event, serial 34, synthetic NO, window 0x1a00001,
    root 0x3b5, subw 0x0, time 77709803, (-892,894), root:(1032,914),
    state 0x0, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 34, synthetic NO, window 0x1a00001,
    root 0x3b5, subw 0x0, time 77710675, (-892,894), root:(1032,914),
    state 0x40, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

FocusOut event, serial 34, synthetic NO, window 0x1a00001,
    mode NotifyGrab, detail NotifyAncestor

With no clear way solution, I've reached out on Stack Overflow: https://stackoverflow.com/questions/70784497/when-using-vnc-how-can-i-get-modshift2-or-modshift3-to-the-remote-session

Update 20220126:

After a few days back and forth with RealVNC's excellent support team (seriously, the £40 license fee was well worth it!), they came back with the fix:

Include the following into your /etc/vnc/xstartup.custom, just before you launch the desktop:

setxkbmap -symbols "pc+gb"

While here, fix your fonts by adding this too:

xrandr --dpi 96

Currently this isn't included in their online documentation but it will be soon.