by kps · 3y ago · 0 comments
Modern terminal emulators can do this using the xterm modifyOtherKeys protocol, which sends escape sequences for such combinations.
It's all very tricky and quite an arcane art but it's possible to get, for example, the "Hyper" modifier when Emacs is ran inside an XTerm (that is: in "-nw" / no-window mode).
Maybe I should add a section about it though; KiTTY also seems to have some new keyboard protocol thingy now.
Meta: I'm not among the downvoters; on the contrary I aim to upvote any on-topic reply (although I don't always get back to a thread, and anyway I suspect all my votes are shadow-ignored).
1a) try to figure out what the escape code for the play/pause key is 1b) it still suffers from the issue that esc keypresses cannot be distinguished from other escape codes 1c) The keyboard protocol can be turned on/off by user config, so there is no robust way for software running in the terminal to know if it is available or not. 1d) it does not support any modifiers beyond the basic 4 1e) It has no support for lock keys num lock/caps lock 1f) It has no support for alternate keyboard layouts 1g) it has no support for shifted keys 2) How does one represent release events in modifyOtherKeys?
xterm has a long and convoluted history of coming up with poorly designed hacks that the entire ecosystem has to carry around forever afterwards. Not wanting to support these mis-faetures is an entirely reasonable position.
Likewise, programs don’t really need to know if the terminal supports an extended set of key combinations, because they can just react to them if they arrive. If they don’t arrive, then either the terminal doesn’t support that feature or the user didn’t type that key combination; either way the program needs to do nothing.
As for modifiers, good look finding a keyboard that supports more than the basic four. No need for xterm to go out on a limb and support something you can’t use anyway.
And who cares about num lock and caps lock? I’ve never seen any program care what state they were in. Well, GDM does warn you if capslock is on during a password prompt, but that is very niche.
Terminals have never operated on scan codes, so keyboard layouts are irrelevant. The application doesn’t really care what button you pressed to get a Q, just that you typed a Q.
Likewise there has never been support for key release events on terminals. I suppose it’s useful for games, but in most other situations the user will have autorepeat configured and that will handle it.
Why should xterm go out on a limb and invent a scheme that tries to cover every possible future need, even needs that are not in evidence? Better to implement something simpler that just covers what is actually needed. It can always be extended later.