nightkr / flickboard

Flicking keyboard for Android
GNU Affero General Public License v3.0
124 stars 25 forks source link

Ctrl and Alt don't work in Termux #147

Closed allthelazorz closed 7 months ago

allthelazorz commented 7 months ago

Context

Ctrl and Alt don't work in Termux (I have tried Termius, and surprisingly, they work there fine). I used them a lot with MessagEase, several combinations: Ctrl-d exits the terminal, or the current SSH session Ctrl-c terminates the running program, or discards the currently typed command Ctrl-r searches in shell history Ctrl-u/k deletes to the beginning of the line/end of the line Ctrl-a/e jumps to beginning of the line/end of the line Ctrl-y pastes from shell clipboard Alt-y cycles through recent clipboard entries Alt-backspace deletes a word backwards Alt-d deletes a word forwards And lots of others that make using the terminal easier/faster, they are muscle memory for me. And of course, there are programs that require using them, for example "screen" uses the Ctrl-A prefix for all of its shortcuts, or text/code editors, some of which you can't even exit without control characters.

I know that one easy solution would be to use an other terminal emulator app where the modifiers do work, but Termux is probably the most powerful of them all, it's free and open source, so I would like to continue using it daily. It also has an optional small on-screen bar where you can activate these modifiers, but that requires looking at it, and is more inconvenient than just swiping from the spacebar. Most of other keyboards that I have tried have no problem with these modifiers in Termux, one example is Hacker's Keyboard. I don't know what the difference is compared to FlickBoard in the way they send the control characters, unfortunately.

Steps to reproduce

  1. Open Termux
  2. Swipe top-left from space (ctrl label appears)
  3. Type "d"
  4. The letter "d" appears in the command line

Expected behavior

Termux should exit after typing Ctrl-d

Actual behavior

Termux doesn't exit

Android version

Android 14

Device

Samsung Galaxy S21 5G

Other details

No response

Acknowledgements

nightkr commented 7 months ago

Yeeah, Android effectively has two different keyboard APIs, raw keyboard events ("X key was pressed", "Y key was released") and access to the underlying text field ("add XYZ characters"). Currently we use the former for setting modifiers but the latter for everything else, which means that the modifiers are applied "ambiently", but not to the specific text input events.

The raw keyboard event API isn't universally great either, since it can't convey characters that aren't explicitly supported (RIP accents and any hope of CJK input), so we'd probably need to switch between the two on the fly.

allthelazorz commented 7 months ago

MessagEase has an option in the settings, "Character-Based Ctrls", "enables pure ASCII control characters to be sent". Last time I tried, it seemed like Ctrl worked properly in Termux regardless of the option enabled or not, though. We might have some toggle in FlickBoard too, that changes the way modifiers are sent.

nightkr commented 7 months ago

ASCII control characters are a different thing (like the bell "character").

nightkr commented 7 months ago

Should be fixed once v0.0.14 is released.

Screen_recording_20240408_183546.webm

allthelazorz commented 7 months ago

Beautiful, thank you! This was one of the last things I was missing from FlickBoard.