Hmm. Let's say we want to allow for 128 keys. That's 16x8, so 24 lines.
Or... sqrt(128) = 11.314 ... which needs to be rounded up to 12x11, so 23 lines.
OK, 23 fits your chip and 24 doesn't, but in general Nx8 isn't particularly inefficient.
The worst waste of lines comes from modifiers on non-NKRO boards :-/