8 ms·
Comprehensive Keyboard Handling in Terminals
- 3np 4y agoI'm not sure I agree that terminal applications should get access to the whole range of modifiers. It's nice having a certain key dedicated to the WM or macros and know there will be no conflicts.
- eviks 4y agoWhich certain key? It's different per user, so no way to have a common list to exclude. Anyway, there are other better mechanisms to resolve the conflict instead of crippling the app
- Findecanor 4y agoOn Mac, the "Super"/"Command" key controls the terminal app. On Linux, I sometimes wish I had a Command key instead of the Control key being used by both the terminal and programs in the terminal. On X11, "Super" is often mapped to the window manager/the desktop environment, likewise on MS-Windows where it is the Windows key. BTW. "Hyper" is available also on Mac, by default mapped to Shift+Control+Alt+Command but it can be remapped to another key. That key combination is emitted by the "Office key" on some Microsoft keyboards, and is used in MS-Windows for launching a component in their Office pack, or the Emoji picker. So, there are lots of opportunities for configuration, and conflicts. IMHO, It would be a "nice thing to have" if users could configure their text-mode programs to use more modifiers, sure ... but as long as they are the only users of that config. I don't think a text-mode program should map Super or Hyper by default.
- Version467 4y agoThe command key being different from the control key in macOS is really one of its biggest out-of-the-box strengths fro people who use the terminal a lot. It's really quite helpful to have different modifier keys for different "system layers". In addition to the Hyper key, there's also the "Meh" key, which is Shift+Control+Command and basically not used by any application. I use it as my default macro hotkey.
- TacticalCoder 4y ago> BTW. "Hyper" is available also on Mac, by default mapped to Shift+Control+Alt+Command but it can be remapped to another key. I dedicate "Super" to my WM and Hyper to quite a few things but... Hyper is a hack for the USB specs do not have the concept of the Hyper key. So Hyper support is always a kludge.
- kps 4y ago> On Linux, I sometimes wish I had a Command key instead of the Control key being used by both the terminal and programs in the terminal. This is precisely why I prefer KDE — it's feasible to move GUI shortcuts off Control. (It could and should be easier, since there's a global setting deep in Qt somewhere, but it's only exposed on MacOS.)
- deleted 4y ago[deleted]
- eviks 4y agoIt's very nice to see some progress in this moldy part of a technology junkyard
- galkk 4y agoKovid is one of those 10x engineers for me. I love kitty and use it every day, calibre does it job too. Great, that he tries to make progress in terminal area, that, as for me, is quite archaic as of now.
- nextlevelwizard 4y agoI have never quite understood what the benefit of using kitty is. My default terminal emulator just isn’t using that many resources and I don’t get why I would even want GPU rendering for text. What problem does it solve for you?
- kzrdude 4y agoTerminals have some infuriating limitations, like imagine not being able to tell the difference between Esc + A or Alt + A as an application. Or that tab and Ctrl + I produce identical input. Kitty has a new keyboard handling protocol, and Neovim supports it. So if you use kitty, you can use key mappings in neovim in a more predicatable and flexible way.
- kps 4y agoBut xterm and xterm-compatibles have been able to do this for over a decade (CSI > 4 ; 2 m).
- nextlevelwizard 4y agoWhile that sounds like a good thing is Esc+<key> really that useful of a bind when you already have Ctrl/Alt + <key> and you can get twice the keys if you add shift in the mix. Of course your workflow is yours.
- kzrdude 4y agoWhen Alt+a looks the same as Esc+a, then the program has to wait biefly after it sees you press Esc - the continuation could mean it's really Alt+a you want to send. That latency interferes just with a plain Esc key press. There's no weird use case in this.
- durazabu 4y agoGlad to see this page featured again. Is there any advance on that front? Previous submission was 2 years ago. https://news.ycombinator.com/item?id=27193661 https://news.ycombinator.com/item?id=27193661
- aumerle2 4y agoThe progress is that this protocol has been implemented in many widely used programs, such as vim, neovim, helix, kakoune as well as at least two more terminal emulators, wezterm and foot in addition to kitty.
- durazabu 4y agoIt seems like the protocol has not been implemented yet in neovim. https://github.com/neovim/neovim/issues/14400 https://github.com/neovim/neovim/issues/14400
- aumerle2 4y agoIt has, just not fully. See the very first checkbox in the link you posted. Indeed this protocol is designed so applications can pick and choose what parts they want to use.
- gpanders 4y agoIt has been implemented to a degree that it is useful for most users. For instance, you can now map Control-I and Tab separately, as well as keys like Control-1, Control-2, Control-;, etc.
- zokier 4y agoAt some point one might consider if it would be simpler and better to just have some way to pass wayland-compatible events instead of inventing yet another protocol. So much stuff has now been thrown into terminal layer in a way that is not particularly elegant and what we already have perfectly good protocols for.
- tyingq 4y agoHow would that traverse ssh, tmux, etc?
- cellularmitosis 4y agoAnd what about mac and windows? And X11 for that matter.
- hendersoon 4y agoIn a development that will surely confuse nobody, the terminal emulator linked in this thread (kitty) is completely separate from another terminal named KiTTY. I assume there's some drama behind this. Anyway, this one is for Linux/MacOS only while KiTTY is a PuTTY fork for Windows only.
- gpanders 4y agoIt is briefly mentioned in this post, but this work is based on a proposal by Paul Evans [1] (creator of libtickit and libvterm, among others). Kovid deserves credit for addressing some of the issues in the original proposal, and for documenting it well. But Evans deserves credit as well for formulating the original idea. Note also that this is not the only solution to this problem. Xterm has had its own solution for a long time called modifyOtherKeys [2] which has been supported by Vim and iTerm2 for quite some time (I believe foot supports it as well, perhaps others). Of course people have different opinions on which approach is “better”, though empirically it seems like the CSIu/“fixterms”/kitty approach has a lot more momentum at present. [1]: http://www.leonerd.org.uk/hacks/fixterms/ http://www.leonerd.org.uk/hacks/fixterms/ [2]: https://invisible-island.net/xterm/modified-keys.html https://invisible-island.net/xterm/modified-keys.html
- kps 4y agoI know mlterm is one that supports modifyOtherKeys. Fragmentation is unfortunate, especially since there's no termcap/terminfo property that indicates which form(s) a terminal supports, and so many terminals already identify themselves as ‘xterm’ without being remotely close to xterm-compatible.
- ibiza 4y agoThere's an even richer protocol, `?9001h`, developed by the Microsoft Terminal team, designed to maintain the fidelity of INPUT_RECORD events. These are the events seen by console programs in Win32. It's quite nice. https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md https://github.com/microsoft/terminal/blob/main/doc/specs/%2...
- eviks 4y agoIn what way is it richer? I've skimmed through the linked doc, saw the mention that it is richer, but didn't see an explanation of the extra functionality is available
- ibiza 4y agoEvents include key scan codes for one. The end of the doc contains a pros & cons section of the alternative approaches. https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md#options-considered https://github.com/microsoft/terminal/blob/main/doc/specs/%2...
- jwr 4y agoIf this were widely adopted, it would do wonders for Emacs. Right now Emacs is unusable in remote terminal connections for many of us, because there is no way to get key combinations like Super-Shift-G to work.
- donio 4y agoI agree that Emacs would greatly benefit from this feature but "unusable" a overly dramatic. It's an inconvenience. I use Super on the desktop as much as anybody but I manage with remote tty sessions (including termux from phone) just fine. I just make sure that I also have a terminal-friendly binding for anything critical that I have on Super.
- denotational 4y ago> "unusable" a overly dramatic Disagree. I used to use Emacs with evil-mode, but I gave up because of this issue. If I entered `ESC` then `k` (i.e. return to normal mode and move up a line) too quickly on an SSH connection, there was a good chance the `read` syscall on the PTTY file descriptor would return two characters (determined via `strace`) instead of two subsequent calls returning a single character each. This makes it literally impossible for Emacs to distinguish it from `M-k` (i.e. `kill-line`), so I’d “randomly” see lines deleted before I figured out what was going on. The effect is a lot more pronounced over SSH where a spike in network latency can cause two subsequent TCP segments to reach the host essentially back-to-back (or even be retransmitted as a single segment), leading to this behaviour of `read` returning two characters.
- donio 4y agoI see. I don't use the vi modes so it never occurred to me that ESC vs meta would be timing sensitive.
- jwr 4y agoI guess it depends on how many Super shortcuts you use, and for how many years you have been using them. In my case, both numbers are into double digits, so.
- ithrow 4y agoDoes kitty lets you remap modifiers like iterm2? https://i.stack.imgur.com/hd5Yi.png https://i.stack.imgur.com/hd5Yi.png
- comfypotato 4y agoShoutout to Alacritty for having Windows support. Would have adopted kitty at the time for the reasons mentioned in the article (much more mature) but Alacritty does the trick. Not sure how it deals with modifiers etc. in the plumbing, but the configuration is plenty straightforward to access everything from terminal applications that can use lots of bindings.