arrow keys to select, as seen in Menus extension?

I’d like to use a menu effect in the glulx/inform 7 project I’m working on, similar to the Menus extension.

I’m not looking for something that does everything menus does, though. I don’t want to change the status line or nest menus as in a help/hints system, and I’m comfortable enough rolling my own logic for what options appear and what they trigger.

I’m just looking for the arrow-keys-to-select-menu-item effect. I assume it’s just a matter of drawing the menu with one thing highlighted and then redrawing with the next thing highlighted if someone hits the down key, but I can’t quite figure out how that’s done, even looking at the code for menus.

I’d be grateful if anyone can point me in the right direction.