Repository navigation
Description
Utilizing the UHID keyboard with scrcpy and the Danish keyboard layout does so that AltGr cannot be utilized.
System Specs
- Operating system: Arch Linux
- Display server protocol: Wayland
- Compositor: Sway
- Keyboard Layout: Utilizing the danish keyboard layout as can be seen here:
(source of picture here)
Phone specs
- Phone: Google pixel 9 pro XL
- Operating system: GrapheneOS.
- Keyboard: Using the default android keyboard bundled with GrapheneOS, Danish layout.
Description of problem
Scrcpy is running through xwayland.
Running
scrcpy --video-codec=h265 --max-size=1920 --max-fps=60 --no-audio --keyboard=uhid --shortcut-mod lalt -V verbose and pressing+releasing AltGr gives the following output:
VERBOSE: hid keyboard: key down scancode=e6 (230) mod=00
VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00
VERBOSE: hid keyboard: key up scancode=e6 (230) mod=00
VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00
However, upon pressing e.g. AltGr+2 to input the character '@' in scrcpy, the character is not input.
'2' is simply input.
There is an odd thing, however. The ´-button (located just to the left of the backspace button on my keyboard) does not input anything in scrcpy when pressed on its own.
However, if the ´-button is pressed twice with AltGr held down in scrcpy, the character ´ is input.
This character is normally input when pressing the button on its own without AltGr in my operating system.
The following output is obtained by
Pressing AltGr-->pressing the ´-button twice -->releasing AltGr
in scrcpy:
VERBOSE: hid keyboard: key down scancode=e6 (230) mod=00
VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00
VERBOSE: keys[2e] = true
VERBOSE: hid keyboard: key down scancode=2e (46) mod=00
VERBOSE: input: UHID input [1] 00 00 2E 00 00 00 00 00
VERBOSE: keys[2e] = false
VERBOSE: hid keyboard: key up scancode=2e (46) mod=00
VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00
VERBOSE: keys[2e] = true
VERBOSE: hid keyboard: key down scancode=2e (46) mod=00
VERBOSE: input: UHID input [1] 00 00 2E 00 00 00 00 00
VERBOSE: keys[2e] = false
VERBOSE: hid keyboard: key up scancode=2e (46) mod=00
VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00
VERBOSE: hid keyboard: key up scancode=e6 (230) mod=00
VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00
AltGr works completely fine in scrcpy with the --keyboard=sdk option, however.
A recent-ish comment in this issue #4725 describes a similar problem to mine.
Activity
rom1v commentedon Sep 27, 2026
Fixed by #7051. Please test before I merge it.
1eksister commentedon Sep 27, 2026
I'll test it throughout the day Monday and reply asap.
1eksister commentedon Sep 27, 2026
I decided to just try it quickly before I sleep.
I built the commit using the guide for building found here
I used option 2 to build with the prebuilt server binary, rather than option 1 where you compile everything from source. I had trouble compiling everything from source- I didn't understand the instructions regarding setting the path to the Android SDK (my sleepiness may be a factor in this, I can figure out how to compile from source if needed tomorrow)
Regardless, I managed to successfully build the commit using option 2.
I ran scrcpy using the following command after building:
./run x --video-codec=h265 --max-size=1920 --max-fps=60 --no-audio --keyboard=uhid --shortcut-mod lalt -V verboseAltGr+2 now inputs
@. The keycombinations AltGr-1 thorugh AltGr-9 all produce input, with the exception of AltGr+6 and AltGr+1.AltGr+(letter on keyboard) produces output on my operating system. The keycombination also produces output in scrcpy, with some random exceptions (e.g. AltGr+U produces a ↓ on my operating system, but nothing in scrcpy)
However, now the
´-button(the button to the left of my backspace) produces no input. AltGr+the´-button produces|. There is also no output in the terminal when pressing the´-button alone.The
^/~-button(located just to the right ofÅon my keyboard) does not work either. There is no output in the terminal when the button is pressed.Best regards, and thank you for a wonderful application and your help!
rom1v commentedon Sep 27, 2026
Thank you for the tests. So it seems the AltGr key is now correctly forwarded.
The fact that some combination do not work is probably due to keyboard layout differenced between your computer and Android. MOD+k to configure the Android layout (but it is likely that there is no exact match).
1eksister commentedon Sep 29, 2026
I have clicked MOD-k and my keyboard layout for "scrcpy" is set to "Danish". Nonetheless, the
´"button remains unusable. No terminal output when pressing the button, as stated.However, AltGr works as expected now. Is it not better I open a separate issue for the problem of the
´-button and the^/~-button not working for the Danish keyboard layout?Thank you so much for your time and effort in developing this application. If I can assist in any way within my capabilities, do not hesitate to request further logs or help.
Handle AltGr as Right-Alt