Android 上 Chrome 网络浏览器中的 VSCode:如何使 {[]} 工作?

发布于 2025-01-14 13:40:35 字数 1029 浏览 2 评论 0原文

我在 RPi 4B/8GB 上部署 VSCode 服务器,以便在浏览器中从 Android 平板电脑访问 VSCode,无需安装任何 termux。就我而言,termux 上的 VScode 不是一个选择,因为我正在开发需要额外系统权限的系统附近容器工作负载。

  • VSCode 服务器是:coder/code-server
  • 平板电脑是带有三星键盘盖的三星 Tab S7+。
  • 最新的 Chrome 应用版本。
  • 平板电脑使用 terminus 通过 SSH 隧道运行到 VSCode 服务器端口的端口转发。
  • 我使用标准的 104 键键盘布局;我已转储布局并将其保存为 .local/share/code-server/User/keyboardLayout.json

不幸的是,这对于与 AltGr 相关的键不起作用。启用开发人员键绑定(原文如此!)输出后,我能够在按 AltGr+8 时捕获此输出,它应对应于 [:

开发者键绑定日志输出

这表明 Chromium实际上发送[ 键,但使用 AltRight 而不是 AltGr。 (顺便说一句,Android 上的 Firefox 实际上会发送 AltGr,但有其他怪癖,使其完全不适合浏览器中的 VSCode。)

不幸的是,我找不到任何有关布局 JSON 模式如何工作以及如何使用 VSCode 或 Electron 的文档。修复甚至不发送 AltGr 的情况。

我该如何解决这个问题并制作正常工作的键盘布局?最好,任何修复不仅应该在文本编辑器中起作用,而且还应该在终端中起作用。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

朮生 2025-01-21 13:40:35

我在使用 Gitpod 的 VSCode 中使用带有物理键盘的 Android 平板电脑时遇到了类似的问题,我的问题与使用 AltGr 时 VSCode 执行 Alt 的键绑定命令有关。我的解决方案是删除所有冲突的 Alt + 命令绑定。这是我的 keybindings.json 用于重置数字键。

[
    {
        "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"
    }
]

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"
    }
]
小糖芽 2025-01-21 13:40:35

就我而言,Shift+AltRight 将提供 AltGr 功能。我正在 Android 平板电脑上的 Chrome 上使用 VSCode for Web 进行编码。在物理键盘上,键帽实际上显示为Alt Gr

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文