Remake this with kb2040.
Should be possible to ask for expected key sequence beforehand, then do really fast pin testing as each key is held down for a second or so. Might have to have the first key held of longer until a mapping match is found, similarly with rows if key not detected, follow onscreen prompts.
Accept key sequence as tuple of tuples or string, to allow basic keys or also row/col for more gamepad/midi/accessibility/unthinkable inputs.
Have config mode with usb storage disabled if after reset the onboard button is held at 2s, suggest to user after counting 1 long second (it checks at 2). Save keymap in toml or JSON or both, with a name or next available Id. Include number of pins and check files for possible matches of unknown future keypads, prioritizing those mapping attempts over other sequences.
https://hackaday.com/2023/10/12/keypad-interface-module-reverse-engineers-pinouts-so-you-dont-have-to/