News for hackers. Stuff that matters.
Re:Why Is It So Hard to Detect Keyup Event on Linux? by pjc50 on Monday May 17, 2021 @11:05AM (#27184277)
> A tty doesn't know about the concept of key press or key release events. It only knows about 'data stream in' and 'data stream out'.

This is basically the long and the short of it; it's a very old API, and retrofitting key-up detection reliably is a serious problem.

Re:Why Is It So Hard to Detect Keyup Event on Linux? by CoastalCoder on Monday May 17, 2021 @11:29AM (#27184565)
Perhaps this is nitpicking, but I don't think the issue here is "data stream" vs. not-"data stream".

Perhaps a better distinction is "data stream of characters" vs. "data stream that can express key events (and perhaps other stuff as well)".

Re:Why Is It So Hard to Detect Keyup Event on Linux? by swiley on Monday May 17, 2021 @11:42AM (#27184729)
This is correct, plan9 continues using a data stream but puts events in the data stream rather than characters.

Even on Linux the low level kernel API for getting keypress events works this way.

Re:Why Is It So Hard to Detect Keyup Event on Linux? by icedchai on Monday May 17, 2021 @12:32PM (#27185310)
It's really a lower level protocol issue. The serial terminals upon which the "tty" model is based had no event stream outside of characters being sent or received. There are events provided by the serial port itself and delivered out-of-band though (example: modem DCD line drops, SIGHUP is generated.)
Re:Why Is It So Hard to Detect Keyup Event on Linux? by drran on Monday May 17, 2021 @12:53PM (#27185542)
To fix this low level problem, someone will need to modify xterm, or libvte, or any other terminal, to send escape sequences for key release events, when such mode is requested by an application.
Re:Why Is It So Hard to Detect Keyup Event on Linux? by patrec on Monday May 17, 2021 @01:09PM (#27185704)
Already done. Kitty and other modern terminals have an extended keyboard interface which allows to detect keypress, keyrelase and arbitrary key combinations (unlike legacy vt100-style terminal emulators, where e.g. Tab and Ctrl-I are indistinguishable). For backwards compatibility you need to switch to this mode by sending an escape sequence.

https://sw.kovidgoyal.net/kitty/keyboard-protocol.html

Re:Why Is It So Hard to Detect Keyup Event on Linux? by eikenberry on Monday May 17, 2021 @05:30PM (#27188692)
> and other modern terminals

Do you know of any source documenting which terminal emulators support this feature other than kitty?

Re:Why Is It So Hard to Detect Keyup Event on Linux? by patrec on Tuesday May 18, 2021 @05:18AM (#27192639)
Have a look here: https://gitlab.freedesktop.org/terminal-wg/specifications/-/...

Basically Kovid Goyal, the author of kitty, volunteered to write a spec, based on the work he did for kitty, but got fed up with what he perceived as pointless bikeshedding. The authors of other terminals represented in the terminal-wg (e.g. iterm2, mintty and vte -- which powers terminator, gnome-terminal and others) kept going for a bit, but there is no shared spec yet and I haven't checked if anyone else other than Goyal has implemented something at this point (I thought vte had, but I didn't immediately find it when I looked). It also looks like it might take some time till some de-facto standard emerges.