class Chamomile::Keymap

Declarative keymap with composable guard conditions.

Usage:

@keymap = Keymap.new
  .bind("q")               { quit }
  .bind(:tab)              { focus_next }
  .only(-> { !modal_open? }) do |km|
    km.bind("j")           { scroll_down }
    km.bind("k")           { scroll_up }
  end

Then in update:

def update(msg)
  return @keymap.handle(msg, self) if msg.is_a?(KeyEvent)
  ...
end