Keyboard Swipe DistanceOctober 29, 2019
iOS 13 introduced a swipe keyboard (officially called QuickPath) to the base operating system. This has been available in other operating systems as well as in various third-party keyboards for some time. However, I’m unadventurous and so this was the first time that I’ve tried it out. I’ve been enjoying it but found that some words seem far less efficient to type by swiping (for whatever that means on a tiny, mobile keyboard).
I’ve written a Go package and small CLI to calculate the swipe distance required to type words. It does some simple maths based on the pixel coordinates of key in a screenshot of a keyboard. Using this program we can calculate the total swipe distance required to type all of the words in the dictionary. A caveat is that there may be shorter ways to type some words if they have a unique swipe prefix so that the word can be identified without completing the swipe. This will be ignored for these calculations.
Let’s start by just getting the top 10 longest-to-swipe words from the default dictionary on my machine.
$ cat /usr/share/dict/words | swipedistance | sort -k 1 -n | tail -10 7062.577492 307.068587 pseudolamellibranchiate 7066.836197 336.516009 pentamethylenediamine 7092.310552 354.615528 paraphenylenediamine 7100.013821 338.095896 pseudohermaphroditism 7112.534633 323.297029 electroencephalography 7159.586349 311.286363 phenolsulphonephthalein 7201.797546 313.121632 Pseudolamellibranchiata 7239.048156 314.741224 scientificogeographical 7246.974277 301.957262 formaldehydesulphoxylate 8162.285953 388.680283 mandibulosuspensorial
Those… are some impressive words. Unsurprisingly long words require more swipe distance in order to type them. This isn’t exactly a revelation. What may be more interesting is words which require a disproportionate amount of swiping for their length. The second column in the output divides the total distance by the number characters in the word.
$ cat /usr/share/dict/words | tr 'A-Z' 'a-z' | uniq | swipedistance | sort -k 2 -n | tail -10 4455.781192 495.086799 malayalam 3502.734049 500.390578 amalaka 3002.451554 500.408592 palame 2017.697946 504.424486 papa 4614.467659 512.718629 anapanapa 3081.300031 513.550005 palama 2588.000000 517.600000 alala 3109.131964 518.188661 jalapa 2664.697946 532.939589 papal 5124.844360 569.427151 palapalai
Note: there were some duplicates in the output without the additional
uniq parts of the pipe.
This list is a little more interesting! We can see words like “papal” near the top of the list which makes a lot of sense when we look at the keyboard. The word requires four full-width swipes across the keyboard in order to type it. All of the other words in the list seem to follow a similar pattern: they all contain long substrings of alternating letters on the extreme left and right of the keyboard. Let’s do another check but exclude characters on the far left and right of the keyboard.
$ cat /usr/share/dict/words | tr 'A-Z' 'a-z' | uniq | grep '^[^qazplm]*$' | swipedistance | sort -k 2 -n | tail -10 3365.101010 373.900112 toxicosis 3418.436110 379.826234 crownwork 3048.202226 381.025278 widowish 2675.409214 382.201316 toxosis 1544.559598 386.139899 sown 2706.518534 386.645505 sorosis 3096.161916 387.020240 downtown 1162.358662 387.452887 lwo 1557.439244 389.359811 soso 2354.619313 392.436552 disown
These words are a little more varied and starting to get pretty interesting! We do see common patterns again e.g. “so” and “is”. There’s probably some filtering we could do in order to filter out these substrings but I’m worried that we’d eventually just regress to the longest word wins situation in our first example.