Hacker News new | ask | show | jobs
by arp242 753 days ago
Hence "or read key input". And:

> Key input handling is kind of a mess, and this is where I really recommend using a terminfo library if at all possible. This also avoids the whole backspace/delete key confusion (less of an issue today than it used to be, but still exists).

Of course lots of applications don't use backspace or delete; sometimes you just want the ability to select between 3 items with j/k and arrow keys, or something like that. And if this is something just for yourself or a limited audience then it's fine to just read that from stdin and not worry too much.

2 comments

I guess my point is that even for key input, you don't need terminfo. Modern terminals, and I would agree with your definition of that, all use the same keyboard encodings. There is the notable case of backspace/delete you mentioned but as I said - you can treat both as a backspace press.

All of that said, I am a huge proponent of the kitty keyboard protocol. I would love to live in a world where the "default" encoding of keys is done with the that protocol (with the disambiguate flag on)

> I guess my point is that even for key input, you don't need terminfo.

Right, I read that the other way round ("no, you do need terminfo for key input")!

For basic input it's fairly straight-forward, and even for various "special" keys like arrows and function keys it's not too bad: just check from a list.

But with modifier keys it gets more tricky; lots of that isn't even in terminfo and requires "special" handling.

If you know how this works and you know what you're doing it can be fine, but for most people it's far easier to just use a terminfo library that does this for you.

And yeah, Kitty keyboard protocol being the default would be brilliant. Right now support is (far) too flaky though, so maybe in 5 to 10 years.

you are replying to a comment which specifically explains why it disagrees with the text you quoted from your essay; what is the point of repeating it?

if someone found it unconvincing the first time, or found rockorager's rebuttal to it convincing, hopefully a mere repetition of your comment will not change that. and, if they found it convincing the first time and found rockorager's rebuttal unconvincing, repeating it is unnecessary