project-pegaprox icon indicating copy to clipboard operation
project-pegaprox copied to clipboard

[Bug] Console paste types wrong symbols on non-US keyboard layouts

Open grupoaxium opened this issue 2 months ago • 2 comments

Describe the bug

The console paste feature sends shifted symbols using a fixed US keyboard mapping. On guests with a non-US layout, those symbols come out as different characters. With a Spanish layout, pasting @ produces ". Letters and digits are pasted correctly, and typing the same characters manually works, because the browser sends the real key events.

In web/src/node_modals.js, typeTextToVM uses the SHIFTED_US table and sends Shift plus the US base key (for example, '@': 0x32, Shift+2). On a Spanish layout, Shift+2 is ", while @ is AltGr+2.

Steps to Reproduce

  1. Use a Windows guest with a Spanish keyboard layout. The datacenter also has keyboard: es.
  2. Open the VM console in PegaProx.
  3. Paste a text containing @, #, ", ( or _, for example into Notepad or a password field with "show password".

Expected behavior

The pasted text appears unchanged in the guest.

Environment

  • PegaProx Version: 1.2.0 (Debian package 1.2.0-1)
  • Installation Method: Other: APT repository packages.gyptazy.com, Debian trixie
  • OS: Debian 13 (trixie); guest: Windows Server with Spanish (es-ES) keyboard layout
  • Browser: Chrome
  • Behind Reverse Proxy? Traefik v3.6 (via Pangolin)
  • UI?

Logs

N/A (client-side keyboard mapping)

Screenshots

N/A

Checklist

  • [ ] I have searched existing issues to make sure this is not a duplicate
  • [ ] I am using the latest version of PegaProx
  • [ ] I've put enough in here that someone can start on it without asking me three questions first
  • [ ] I understand PegaProx is maintained by volunteers in their free time. Nobody is on call, and writing URGENT doesn't get anyone out of bed 🪄

Workaround: type symbols manually instead of pasting, or use RDP.

Suggested fix: take the keyboard layout into account when mapping characters to key events, for example from the datacenter keyboard option, or let the user choose the layout used for paste in the console.

grupoaxium avatar Sep 28 '26 11:09 grupoaxium

Confirmed and fixed on Testing, using the datacenter keyboard option you suggested.

The background, since the table looks arbitrary otherwise: it was added for #653, where pasting into a console produced 1 instead of ! and [ instead of {. Without a keymap configured, qemu resolves keysyms against a US layout and does not assert Shift for the symbol row, so paste has to hold Shift and tap the base key itself, exactly as a hand on a keyboard would. That is correct - but only while the layout really is US, which nothing was checking.

The console answer now carries the datacenter keymap, and paste uses it: on en-us, or when no keymap is configured at all, it keeps doing what it does today so #653 stays fixed; on anything else it sends the plain keysym and lets qemu's own keymap place the character. Your keyboard: es puts you squarely in the second case, so @ will arrive as @. The tests run the shipped paste function against es, de, en-gb, en-us and an unset keymap, so the two halves cannot be traded against each other again by accident.

One caveat that this fix cannot remove, and that is worth knowing: it works because your datacenter has keyboard: es set. If a guest runs a Spanish layout while the datacenter has no keymap configured, qemu assumes US, and neither we nor PVE's own console can know any better - setting the datacenter keymap is the fix in that case, and it is worth checking on any other cluster where you see this.

Verified against a live PVE whose datacenter runs keyboard: de: the console answer now carries de, and paste stops emulating a US keyboard for it.

Thanks for naming the table, the key and the layout. That is most of the work done before anyone opened an editor.

mkellermann97 avatar Sep 28 '26 18:09 mkellermann97

Paste now reads the datacenter keymap from the console ticket and, on es (as well as de, fr, it, pt, pl and en-gb), types each character with the physical key plus Shift or AltGr as that layout needs, so '@' arrives as '@' on your Spanish guest. With a US or unset keymap paste behaves as before, so the datacenter keymap needs to match the guest layout. This ships in 1.3.0.

Sponsoring via https://opencollective.com/pegaprox is what keeps the lights on here, if it's useful to you.

Marcus

mkellermann97 avatar Oct 07 '26 04:10 mkellermann97