Piano key dimensions are a math puzzle
Piano keys are familiar and easy enough to draw if you're not trying to be exact, but if you want label the dimensions with their exact measurements (like in a CAD drawing), it turns into a math puzzle. The problem comes from the groups of two and three black keys.
This article explains it like this:
If you've ever looked closely at a piano keyboard you may have
noticed that the widths of the white keys are not all the same
at the back ends (where they pass between the black keys). Of
course, if you think about it for a minute, it's clear they
couldn't possibly all be the same width, assuming the black keys
are all identical (with non-zero width) and the white keys all
have equal widths at the front ends, because the only simultaneous
solution of 3W=3w+2b and 4W=4w+3b is with b=0.
To unpack that a bit: in that equation, 'W' is the width of each white key at the front (which should all be the same), 'w' is the width of a white key at the back, and 'b' is the width of a black key.) The first equation is for the group of two black keys (separating C, D, and E) and the second equation is for the three black keys separating F through B.
Since it's mathematically impossible, a constraint needs to be relaxed. The article describes ways to make the white keys have slightly different widths at the back.
If we set c=e=(W-5B/8) and a=b=d=f=g=(W-3B/4) we have a maximum
discrepancy of only B/8, and quite a few actual pianos use this
pattern as well. However, the absolute optimum arrangement is to
set c=d=e=(W-2B/3) and f=g=a=b=(W-3B/4), which gives a maximum
discrepancy of just B/12. This pattern is used on many keyboards,
e.g. the Roland PC-100.
When actually building a musical instrument (instead of just drawing the keyboard), there is a further constraint, described in this article:
The black keys on a piano keyboard, instead of always being centered on the dividing line between the two white keys they lie between, are spaced so that the twelve keys which make up an octave are spaced equally as they enter the internal mechanism of the instrument.
But this means that the "key caps" for the white keys should be slightly off-center compared to whatever rod or lever they're attached to. The author speculates about how to divide this up using various units.
(They seem quite annoying to 3D print.)
What a great puzzle!
These articles address the optimal solutions for both evenness and practicality of construction, but I wonder if there's a usability benefit possible to different sizings. I'm just a beginner at piano, but I could imagine having wider d, g, and a keys could make fingerings easier than optimally even widths.
One of the piano's biggest strengths is it's ability to transpose easily between different keys. Changing the width of certain keys might be good when playing in keys that use them but would cause problems when playing in other keys.
Edit: I probably shouldn't say transpose into different keys but play in different keys, as it can be difficult to to quickly transpose between keys compared to putting a capo on a guitar
Take a leaf from computer keyboards and put a bump or some other texturing on C (and maybe F, C# and F# also)
This is done on accordions since you can’t see the bass buttons while playing. It’s unnecessary on the piano since you can look down if you need to. (Also, the black keys are helpful for feeling your way.)