Addressing 45 Inputs Down to 6 pin Output
You can do it with the gpio by scanning the buttons as shown in this example schematic.
Modify to suit your needs.



UPDATE: As @DHLaurelT pointed out, this would require 14GPIO to get the job done.  So it would have to be an intermediary circuit that scanned the buttons and then sent the results to the Pi.