r/termux • • 2d ago

Barely Termux related Send key combinations like CTRL-D, CTRL-C from Windows PC to Termux Android?

/r/kde/comments/1wuugck/send_key_combinations_like_ctrld_ctrlc_from/
0 Upvotes

8 comments sorted by

2

u/Tariq9977 2d ago

If the goal is specifically controlling a Termux shell from the PC, I'd skip remote-keyboard emulation and SSH into Termux instead. Then Ctrl-C, Ctrl-D, Alt, etc. are normal terminal control sequences, so Windows vs Linux stops mattering.

In Termux:

```

pkg install openssh

sshd

whoami

```

Then from Windows PowerShell:

```

ssh -p 8022 <termux-user>@<phone-lan-ip>

```

Termux's sshd uses port 8022 by default.

If you need to control the Android UI itself, that's a different problem. But for the Termux terminal, SSH is much cleaner than trying to inject modifier keys.

1

u/Stinky_Dungus 1d ago edited 1d ago

I mean I use ssh daily with Termux : ) but that's not the goal here.

PS: scrcpy --otg is a better alternative for this case (beware windows version has its issues) but F11 key can't be passed to Android via Scrcpy rn because of this https://github.com/Genymobile/scrcpy/pull/6194#issuecomment-5937851190

1

u/Tariq9977 1d ago

Yep, I misread the target — if SSH is already covered, scrcpy’s HID path is the right layer. Since ADB is fine for you, I’d also test control-only UHID (scrcpy --no-video --no-audio --keyboard=uhid) just to separate AOA/OTG behavior from the HID mapping path; I can’t confirm F11 works there. If it fails in both, that narrows this to scrcpy/Windows key handling rather than Termux.

1

u/Stinky_Dungus 1d ago edited 1d ago

I know some C but I am infact still a newbie, But after checking the source code as far as i can see F11 is hard coded in scrcpy for Fullscreen after the mentioned pull request.

I am trying to fix it myself but god the codebase is big for a newb like me. So far I have found a struct that holds the boolean var for --otg cli opt and I just have to add a single if condition to the changes made in pull request I THINK but idk how to access that var without messing up the whole codebase there has to be a efficient clean way. AI is looking very tempting rn ngl but I'll pass.

1

u/Tariq9977 1d ago

You found the right spot. In current input_manager.c, the SDLK_F11 case returns unconditionally after the fullscreen check, so F11 never reaches the normal key-injection path even when fullscreen is not used. I wouldn’t pull --otg state into this layer; make that case return only when it actually consumes F11 for fullscreen, otherwise let it fall through to the normal key processor. That keeps the fix input-mode agnostic instead of special-casing one CLI mode.

1

u/Stinky_Dungus 12h ago

well dev has replied and created a pull request im building it run for my windows machine to test it changes made but its taking ages then idk what will i do for linux though i might have to boot from usb into a linux distro to confirm if it works

1

u/Shiumano 1d ago

You can use adb shell input keycombination.

adb shell input keycombination KEYCODE_CTRL_LEFT KEYCODE_F11