Headings chooser possible as a plugin?

I think I could do a basic filterbox.

But I’m wondering if it would be possible to have different action based on key presses?

My thoughts are:

Enter: moves cursor to heading
space: show/hide sub level of selected heading
Shift-space: show/hide all sub levels