I’ve been enjoying building terminal apps lately. Which is a weird thing to say, because for years the input handling alone was enough to make me reconsider the whole endeavour. You want gg to go to the top. Simple enough. But then you want g to do something else too, so now you need timeouts. And count prefixes, because 5j should move down five lines. And escape sequences, because arrow keys exist and terminals are cursed. It adds up fast. Every app, the same dance.
So I wrote something, and I keep reaching for it.
github.com/kungfusheep/riffkey
riffkey is just a key input router written in Go. You give it vim-esque patterns like <C-w>j or <leader>f or gg, and it handles the fiddly bits - disambiguation, timeouts, escape sequence parsing. The thing I didn’t expect was how much I’d like using it. There’s a shared config at ~/.config/riffkey.toml so bindings can follow me between apps. Named handlers I can introspect for help screens. Macros now, because I needed them. Push/pop mechanics for modal input.
None of it is clever. It’s just the stuff that was getting in the way, moved somewhere I don’t have to think about it any more.
I’m not sure if anyone else needs this. But I needed it, and now I have it, and building terminal apps is actually fun again.
— P.G.