Skip to content

Right Shift key does not work with UHID keyboard (-K) since scrcpy 4.0 #6983

Closed

Description

@ucbear

Environment

  • OS: Windows 11
  • Scrcpy version: 4.0 and later
  • Installation method: Windows release
  • Device model: Galaxy Tab S11 Ultra
  • Android version: 16
  • Keyboard: K995p
  • **Keyboard layout:**Korean / US

Describe the bug

When using scrcpy with UHID keyboard mode (-K / --keyboard=uhid), the Right Shift key does not work as a Shift modifier, while the Left Shift key works correctly.

This appears to be a regression introduced in scrcpy 4.0. The same PC, keyboard, and Android device worked correctly with scrcpy versions before 4.0.

Since scrcpy 4.0 migrated from SDL2 to SDL3, this might be related to SDL3 keyboard/scancode handling, but I have not confirmed the root cause.

Steps to reproduce

  1. Start scrcpy with UHID keyboard mode and verbose logging:
scrcpy -K -Vverbose
  1. Hold Left Shift and press some keys.
  2. Release Left Shift.
  3. Hold Right Shift and press the same keys.

Expected behavior

Both Shift keys should work as Shift modifiers.

For UHID keyboard input, I would expect:

  • Left Shift: HID scancode 0xe1, modifier 0x02
  • Right Shift: HID scancode 0xe5, modifier 0x20

Actual behavior

Left Shift works correctly. For example, while holding Left Shift:

VERBOSE: keys[51] = true
VERBOSE: hid keyboard: key down scancode=51 (81) mod=02
VERBOSE: input: UHID input [1] 02 00 51 00 00 00 00 00
VERBOSE: keys[51] = false
VERBOSE: hid keyboard: key up   scancode=51 (81) mod=02
VERBOSE: input: UHID input [1] 02 00 00 00 00 00 00 00
VERBOSE: keys[52] = true
VERBOSE: hid keyboard: key down scancode=52 (82) mod=02
VERBOSE: input: UHID input [1] 02 00 52 00 00 00 00 00
VERBOSE: keys[52] = false
VERBOSE: hid keyboard: key up   scancode=52 (82) mod=02
VERBOSE: input: UHID input [1] 02 00 00 00 00 00 00 00
VERBOSE: hid keyboard: key up   scancode=e1 (225) mod=00
VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00

Without Shift, the same keys correctly use mod=00:

VERBOSE: keys[51] = true
VERBOSE: hid keyboard: key down scancode=51 (81) mod=00
VERBOSE: input: UHID input [1] 00 00 51 00 00 00 00 00
VERBOSE: keys[51] = false
VERBOSE: hid keyboard: key up   scancode=51 (81) mod=00
VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00
VERBOSE: keys[52] = true
VERBOSE: hid keyboard: key down scancode=52 (82) mod=00
VERBOSE: input: UHID input [1] 00 00 52 00 00 00 00 00
VERBOSE: keys[52] = false
VERBOSE: hid keyboard: key up   scancode=52 (82) mod=00
VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00

However, when I press Right Shift, it does not work as a Shift modifier.

In particular, I do not see the expected Right Shift HID scancode:

scancode=e5 (229)

or the expected Right Shift modifier:

mod=20

in the verbose output.

The issue is reproducible with scrcpy 4.0 and later, while the same setup works correctly with versions before 4.0.

Could this be a regression related to the SDL2 → SDL3 migration in scrcpy 4.0, possibly in the keyboard event/scancode handling?

Activity

  1. rom1v commented on Aug 10, 2026

    @rom1v
    Collaborator

    I cannot reproduce on Linux:

    Left-shift down and up:

    VERBOSE: hid keyboard: key down scancode=e1 (225) mod=02
    VERBOSE: input: UHID input [1] 02 00 00 00 00 00 00 00 
    VERBOSE: hid keyboard: key up   scancode=e1 (225) mod=00
    VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00 
    

    Right-shift down and up:

    VERBOSE: hid keyboard: key down scancode=e5 (229) mod=20
    VERBOSE: input: UHID input [1] 20 00 00 00 00 00 00 00 
    VERBOSE: hid keyboard: key up   scancode=e5 (229) mod=00
    VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00
    

    To be tested on Windows (I currently can't).

  2. Vishnu070803 commented on Aug 16, 2026

    @Vishnu070803
    Contributor

    hey, I successfully reproduced this! it's true, when switching to the korean layout in windows the right shift fails.

    your were right. the root cause is a regression introduced in commit c8479fe. because of how windows handles the korean layout, sdl3 strips the virtual keycode for right shift (making it unknown), but it still passes the physical scancode (e5).

    that commit aggressively drops any key event with an unknown virtual keycode. this completely breaks uhid mode, since uhid only cares about the physical scancode anyway and is supposed to bypass the os layout.

    i just submitted a fix in PR #6990. it relaxes that filter so it doesn't drop the event as long as the physical scancode is valid. this should fully restore right shift for korean keyboards in uhid mode!

  3. added a commit that references this issue on Sep 5, 2026
    b80edbc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions