Many Buttons -> 1 Input

I've come up with a couple of interesting ways to read in multiple buttons using just one Analogue Input and nothing but a handful of resistors. While it can only detect one button at a time, pressing multiple buttons will not result in phantom key presses, instead it works on a priority system where the highest number button pressed will be registered.
An Excel spreadsheet which calculates the resistor values for a given number of switches is attached (max 20), along with a diagram of a 6 switch tree.

I've also come up with a similar way (untested in anything but simulation) to control an entire 4x4 keypad from just a single analogue pin, though in this case if you press more than one button you will either see the highest numbered one as with the switch tree, or just some random key depending on what combination is pressed.
A diagram of this is attached also.

Hope someone finds it a useful (and cheaper) way to have multiple switches without additional shift registers.

analogswitchtree.xlsx (15.8 KB)

Very well done.

My concern about this method of multiplexing keys, is how badly it fails in practice.

Ok, so it works most of the time. It is used in many consumer products, notably computer monitors and entertainment devices such as MP3 players - those things that imitate, or are imitated by the iPod Nano.

In my experience - just mine mind you - when these things fail and that is, the control system fails so that you cannot use it, the failure is that the control buttons "cipher" or simply control the wrong function.

This is due to moisture ingress to the pushbuttons, which often contain lubricants that may be hygroscopic. Even without the lubricant, a device carried in the pocket - which is where MP3 players generally live - lives in a high humidity (and somewhat salty) environment.

Perhaps I have a high expectation of these devices lasting longer than a year in use, but my collection of 2 or 3 failed MP3 players (as well as those with smashed screens) and a couple of crazy monitors leads me to offer this caution. I am sure I am not the only one to experience this.

{As an aside, the same "cipher" failure should obviously be possible even in digital pushbutton inputs with higher pullup (effective) resistor values.}