termux-app
termux-app copied to clipboard
Terminal emulation: allow configuration of string sent by backspace key
Feature description
The terminal emulation of Termux needs the ability to configure the byte string generated by the "backspace" key on the keyboard (physical, soft, or "BKSP" in the extra-keys row of Termux itself), with keycode KeyEvent.KEYCODE_DEL
. Currently it seems to be hard-wired to send ^?
(ASCII DEL), with no way of changing it. This might be the default expectation of many packages on Linux, but it is not the expectation on many other systems, nor of the upstream packages (ncurses, xterm, etc) - Linux is the odd one out here.
An "advanced" option in termux.properties
would be OK, though a GUI option would be better, and more in keeping with other terminal emulators.
Locally on the Android device within Termux, things are mostly consistent (eg. stty erase
is set by default to ^?
). However, when connecting remotely to other machines, often the remote machine expects ^H
, and there are usually reasons why this cannot be changed - notably not to break compatibility with other clients. Therefore Termux needs to be able to send this character.
The Termux code (KeyHandler.java) attempts to send ^H
if the Ctrl
key is used as a modifier with the Backspace key. However, not all keyboards allow modifiers to be applied to this key (eg. "Hacker's Keyboard" doesn't), and in any case, having to use a modifier for the most common function would be a poor workaround. The other workaround (to type Ctrl-H
directly) is similarly a poor experience.
In addition to an explicit configuration option, it might also be worth supporting the "DEC Private Mode" codes - in this case, specifically ^[[?67h
and ^[[?67l
- as that would allow remote .bashrc scripts to adjust the emulation to match the expectations of the remote machine.
Similarly, the string sent by the "delete" key which appears on some keyboards with keycode KeyEvent.KEYCODE_FORWARD_DEL
(and is available as "DEL" in Termux's extra-keys row) currently seems to be hard-wired to send the DEC/ANSI Keypad Delete sequence ^[[3~
. That should be configurable too (eg. to send ^?
).
Reference implementation Pretty much all terminal emulator programs allow this to be configured with a prominent GUI option - xterm, Gnome Terminal, PuTTY, etc. Elsewhere in the Android world, ConnectBot also allows the action of the backspace key to be configured.
I've spotted issue #212 is essentially the same request, and that's been open for even longer. Please can this be resolved - it's a serious usability issue.
(Confirmed still to be a problem with the latest version of Termux)