VSCode in Chrome web browser on Android: how to make {[]} work?

1.4k Views Asked by At

I'm deploying a VSCode server on an RPi 4B/8GB in order to access VSCode from an Android tablet in the browser, without any termux installation. VScode on termux is not an option in my case as I'm developing system-near container workloads that require additional system privileges.

  • VSCode server is: coder/code-server.
  • tablet is a Samsung Tab S7+ with Samsung's keyboard cover.
  • recent Chrome app version.
  • tablet runs port forwarding to the VSCode server's port via an SSH tunnel, using terminus.
  • I'm using a standard 104 keys de keyboard layout; I've dumped the layout and saved it as .local/share/code-server/User/keyboardLayout.json

Unfortunately, this doesn't work with respect to AltGr-related keys. After enabling the developer key binding (sic!) output, I was able to catch this output when pressing AltGr+8, which should correspond to [:

developer keybindings logging output

This reveals that Chromium actually sends the [ key, but with AltRight instead of AltGr. (On a sidenote, Firefox on Android actually sends AltGr, but has other quirks that make it totally unsuitable for VSCode in a browser.)

Unfortunately, I couldn't find any VSCode or Electron documentation on how the layout JSON schema works and how to fix such a situation where AltGr isn't even sent.

How can I fix this and make a properly working keyboard layout? Preferably, any fix should not only work in the text editors, but also the terminals.

2

There are 2 best solutions below

1
agilejoshua On

I had a similar issue with an Android tablet with physical keyboard in VSCode using Gitpod, my problem was related to VSCode executing keybinding commands for Alt when AltGr was used. Solution for me was to remove all the colliding Alt + command bindings. This is my keybindings.json for reseting numerical keys.

[
    {
        "key": "alt+1",
        "command": "-workbench.action.openEditorAtIndex1"
    },
    {
        "key": "alt+2",
        "command": "-workbench.action.openEditorAtIndex2"
    },
    {
        "key": "alt+3",
        "command": "-workbench.action.openEditorAtIndex3"
    },
    {
        "key": "alt+4",
        "command": "-workbench.action.openEditorAtIndex4"
    },
    {
        "key": "alt+5",
        "command": "-workbench.action.openEditorAtIndex5"
    },
    {
        "key": "alt+6",
        "command": "-workbench.action.openEditorAtIndex6"
    },
    {
        "key": "alt+7",
        "command": "-workbench.action.openEditorAtIndex7"
    },
    {
        "key": "alt+8",
        "command": "-workbench.action.openEditorAtIndex8"
    },
    {
        "key": "alt+9",
        "command": "-workbench.action.openEditorAtIndex9"
    },
    {
        "key": "alt+0",
        "command": "-workbench.action.lastEditorInGroup"
    }
]
0
volkbay On

In my case, Shift+AltRight would give AltGr functionality. I am coding with VSCode for Web on Chrome on an Android tablet. On the physical keyboard, the keycap actually reads Alt Gr.