Bug 391075 - Can’t bind Ctrl+Backspace
Summary: Can’t bind Ctrl+Backspace
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: emulation (show other bugs)
Version: 18.04.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks: 405612
  Show dependency treegraph
 
Reported: 2018-02-26 01:30 UTC by ariasuni
Modified: 2023-08-28 01:18 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ariasuni 2018-02-26 01:30:39 UTC
It is possible to bind specific keys to actions in a shell, e.g. binding the home key to “go to the beginning of the line”. To check the code we need to bind, one can use `Ctrl+V <key or combination of keys>` in bash or zsh.

However, in Konsole, the code reported by Ctrl+V Ctrl+Backspace is `^?`, which means we can’t rebind it (same for Backspace). Konsole should probably act like GNOME terminal in this regard.
Comment 1 Egmont Koblinger 2018-02-26 21:26:49 UTC
> Konsole should probably act like GNOME terminal in this regard.

GNOME Terminal acts like xterm in this regard :)
(https://bugzilla.gnome.org/show_bug.cgi?id=733246)
Comment 2 Ahmad Samir 2018-02-27 12:42:53 UTC
https://phabricator.kde.org/D10884

FTR, you can fine tune the behaviour using Konsole key bindings editor (Edit current profile -> Keyboard -> Edit); for example you can edit the "Default (XFree 4)" bindings:
- In the table, select "Backspace" and change it to "Backspace-AnyModifier"
- Add a new entry by clicking Add and use "Backspace+Ctrl" and "\b" for the "Key combination" and "Output" fields respectively.
Comment 3 Kurt Hindenburg 2018-02-28 04:04:24 UTC
Git commit 5345bbb0afa8edd6ba4909eca2495745df36f6a1 by Kurt Hindenburg, on behalf of Ahmad Samir.
Committed on 28/02/2018 at 04:04.
Pushed by hindenburg into branch 'master'.

Match xterm behaviour when pressing Ctrl+Backspace

Summary:
Change the default keyboard translator to match xterm behaviour:
 - Pressing Backspace without any modifiers sends '^?', ASCII DEL
   character
 - Pressing Control+Backspace sends '^H', BS character

Test Plan:
- Before applying the patch pressing Ctrl+V (to insert verbatim) then
  Backspace, sends '^?'; the same happens with Ctrl+Backspace
- With the patch:
  - pressing Ctrl+V then Backspace sends '^?'
  - pressing Ctrl+V then Ctrl+Backspace sends '^H'

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: ngraham

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D10884

M  +5    -1    data/keyboard-layouts/default.keytab

https://commits.kde.org/konsole/5345bbb0afa8edd6ba4909eca2495745df36f6a1
Comment 4 ariasuni 2018-02-28 10:30:38 UTC
Thanks a lot. Konsole team is awesomely reactive to my bug reports.

I’m not sure how terminfo works, but this should probably be reflected in it to avoid edge cases in shell’s configurations.

Ahmad, I knew I could configure that behavior but I tried and it didn’t work; this is the kind of things that are confusing as hell for people that don’t understand any of the arcane of terminal emulators.

The change made by Kurt will make life a lot easier for people, because this default is the same as several other terminal emulators (references like xterm and urxvt, or the similar GNOME-terminal) and just works without drawbacks (as far as I know).
Comment 5 Ahmad Samir 2018-02-28 11:39:16 UTC
FTR, the way to configure the key bindings in konsole is documented here:
https://cgit.kde.org/konsole.git/tree/data/keyboard-layouts/README.KeyTab
Comment 6 ariasuni 2018-02-28 12:36:14 UTC
It should be included or mentionned in Konsole Handbook then (<https://docs.kde.org/stable5/en/applications/konsole/index.html>).

Should I open another issue about it?
Comment 7 Kurt Hindenburg 2018-02-28 15:25:02 UTC
We can add it to the handbook - I'm never quite sure how many people use that.

The Keyboard tab has a lot of space at the bottom; I wonder if something could be put there.
Comment 8 Christian Herenz 2019-10-30 01:51:29 UTC
After a upgrading my debian stable boxes to Buster I wondered why alt+backspace stopped working in Konsole the way it used to.  After a lot of trial and error I finally stumbled about this revision, which is causing this wreck.  Of course, I can customise it back the way it was by reversing your changes  .. Nevertheless, since the change fixed the intended behaviour but broke an other keybinding I think I need to report it here. Probably something else needs to be added to restore the alt+backspace behaviour, while also having the intended ctrl+backspace behaviour.
Comment 9 Ahmad Samir 2019-10-30 09:01:10 UTC
Could explain in more details, how did Alt+Backspace work before the update? and how does it work now?
Comment 10 Christian Herenz 2019-11-07 18:28:38 UTC
Konsole emulates the XTerm setting "Meta sends escape" - this is pressing Alt+Backspace used to default to emulate the sequence Esc + Backspace.  With the new setting now Alt + Backspace sends Esc + Alt + Backspace.  XTerm does not by default enable "Meta sends escape", but it is hard-coded in Konsole.
Comment 11 Christian Herenz 2019-11-07 18:30:12 UTC
Note also, that your change could be made as a separate profile that comes with Konsole, rather than changing the defaults that have been in shipped with Konsole since version 1.2.
Comment 12 Ahmad Samir 2019-11-07 22:37:54 UTC
Those key bindings are a major pain... :)

Here's how I tested:
- First xterm, I searched online and found one can use
$ stty raw
$ sed -n l
 then press the key binding, the output was:
Backspace: ^?
Ctrl + Backspace: ^H
Alt + Backspace: ^[^? 

I get the same output in konsole with the current default keybinding schema; and also if I create a new schema, based on the default one, and revert the changes i.e. remove these two entries:
Backspace - Ctrl
Backspace + Ctrl

and add the old entry before any of those changes:
Backspace \x7f

Apply the change and start a new konsole window (it seems there is a bug where the new keybinding doesn't get applied except for newly started instances); and I get the same behaviour.
Comment 13 Ahmad Samir 2019-11-07 22:38:22 UTC
For the whole history of these changes:
https://cgit.kde.org/konsole.git/log/data/keyboard-layouts/default.keytab
Comment 14 Christian Herenz 2019-11-08 01:25:31 UTC
I agree that this is a mess, and GNOME Terminal was also plagued by bugs in this respect in the past. Actually, KDE Konsole always seemed to better implement sane settings in XTerm (not the defaults) then GNOME Terminal.  One of the reasons why I like it so much!

Thanks especially to your last link, that shows what is going on.  Actually it appears that in the KDE version that ships with debian buster (current stable) this commit was the last with respect to Alt+Backspace

https://cgit.kde.org/konsole.git/commit/data/keyboard-layouts/default.keytab?id=5345bbb0afa8edd6ba4909eca2495745df36f6a1

When I press Alt + Backspace I get ^[^H - in later commits you have changed this again - but these changes are not in 18.04.0 that ships with debian... Is this correct?  If so, then feel free to close this bug.

On a side note - I can not reproduce the bug of profiles not being applied immediately. If I go to "Edit Current Profile" and change the Keyboard layout the changes are applied immediately - so this might be a regression?
Comment 15 Christian Herenz 2019-11-08 01:30:00 UTC
Here is what I propose - the old set of defaults dates back to a long long time, as can be seen by its name... Nobody nowadays even remembers what XFree is.  Still, these settings have value, and I think that these old settings should be available as a profile (which does not necessarily need to be the default).  So I suggest to have a profile with those old settings (XFree) and a new default, maybe just named Default?
Comment 16 Christian Herenz 2019-11-08 01:58:29 UTC
Just to add, as this was maybe not clear from my inital reply ^[^?
 is the desired alt+backspace behavior.
Comment 17 Ahmad Samir 2019-11-08 16:03:52 UTC
Using the latest .keytab from master should give the behaviour you describe; basically the two rules concerning Backspace mean:
Backspace-Ctrl: will send ^?
Backspace+Ctrl: will send ^H

The first rule also works for Alt, i.e. pressing Backspace without Control will always send ^?.

And the bug I was talking about happens if you edit a keybiding scheme, then apply, the changes don't seem to take effect in the current konsole window (I should open a bug report to track the issue, but I need to test again....).
Comment 18 ariasuni 2023-08-28 01:18:22 UTC
I’m closing this as resolved since the problem I initially reported is fixed, and there was no activity for almost 4 years.

Other problems mentioned in this thread should have their own bug reports, if there are still there/relevant.