Inspired by this video by Matt Parker
The distances between the letter keys of a QWERTY keyboard are somewhat standardised. The keys are square and both the horizontal and vertical spacing are 19.05mm (so if there were no gaps between the keys, their side lengths would be 19.05mm), and the three rows of keys are offset by ¼ and ½ a key size. Here is a diagram:
Your task is simple: given two letters, output the Euclidean distance between their centres (or between any two equivalent relative positions, for that matter) on a QWERTY keyboard as described above.
The rows of the QWERTY keyboard in a more easily copyable format are:
QWERTYUIOP
ASDFGHJKL
ZXCVBNM
Q, A, and Z are aligned to the left with only the ¼ and ½ offsets described above; the keys at the rightmost end (P, L, and M) do not line up as well.
Of course, given the same letter twice, your output should be 0.
Rules
- You may accept input in uppercase or lowercase, and as characters, strings, or ASCII codepoints, but this must be consistent
- You may assume the input will always be valid; behaviour for non-Latin-letters is undefined
- Your output must be in millimeters, and be accurate to within 0.1mm of the actual value
- You may use any reasonable I/O method
- Standard loopholes are forbidden
- This is code-golf, so the shortest code in bytes wins
Test cases
A full list can be found here (original list calculated by Matt Parker, published here)
In Out
A B 87.82
B Q 98.18
G C 34.34
H J 19.05
L J 38.10
P X 143.27
Y Y 0
4 K [behaviour undefined]
Note: of course your keyboard has different measurements. Of course your keyboard uses AZERTY, or Dvorak, or something else. Of course your keyboard is 3-dimensional with keys that aren't completely flat, so the distances vary a little. Of course your keyboard has wobbly keys that mean the distances aren't even constants. Of course you live in a universe with Heisenberg's Uncertainty Principle in which you cannot truly know that the keys are that far apart. This is obviously an idealised model of a keyboard; please don't argue about these things in the comments!
Image above modified from work by Denelson83 on English Wikipedia, used under CC-BY-SA 3.0.
AJ
is precisely \$19.05 \times 6 = 114.3\$ so may we output \$114.24\$ since it is within \$0.1\$, or not since it would not round to \$114.3\$?) \$\endgroup\$