Might Qwerty be optimal on touchscreens?

It's a common misconception that the Qwerty keyboard is designed to slow users down to prevent typewriters jamming. It fact, it's designed to keep commonly consecutive letter pairs apart, so that two adjacent levers won't collide.

(A more fun, but irrelevant, Qwerty story is that it is also designed such that the word 'typewriter' is all on the top row, to make demonstrating it easy. This story, if true, is itself fun but sucks all the fun out of the fact that the longest word that can be typed on the top row of a typewriter is 'typewriter'. One of these is a fun fact, but I've no idea which.)

Nowadays, obviously, there are no swinging arms to collide, so we want the commonly-used keys to be reachable, and if possible to alternate hands as much as possible. Dvorak and Coleman have each had a stab at designing a better layout, but both aimed at the computer keyboard.

But increasingly, I type on my phone, using one very mobile thumb. I can get to any point on the screen, more-or-less right away -- but sometimes I miss, and usually the phone figures out what I meant and autocorrects it. So maybe the most important thing about any given keyboard layout is how likely it is that a typo will result in a real word that the phone isn't to know isn't what I meant.

I wondered if suddenly Qwerty might be optimal again -- separating pairs of letters that can be swapped to make another real word and that appear next to each other in English words aren't totally different goals. So I thought I'd investigate.

So first I loaded the CSW12 Scrabble word list, and worked out a big table of how many places in the list you can replace each letter with each other letter to create a new word.

ABCDEFGHIJKLMNOPQRSTUVWXYZ
A1766813055253182216252418015208477166401471729754839534532898522015458530
B176124012382841157112377591360406100313837611571579141407112713447439883670366151
C6811240110937587612188431622611102100410361379265141824111718321783120418816153274209
D3051238110971577614457092052999421600146718382271242187549109792348107549726135616307
E52532843757151865534544712224599381010683343447049562123173418938729157216257
F18211578767761867235927626135784682963212610401178210371121573876203020389
G216112312181445553723556186333747812810101319110183991411941514103373669130371180
H2527758437094545925561372616411186979635260109861079121514538123980534356137
I418091162205471276186137351295191303802786154338752533126714220023111828
J1536026129922261333261351173113012242733123443203461125196713666
K208406110294245935774764112911794777989214591150816929134071379517119273180
L477100310041600938846812118651931194714201938479136315327118762049286599899142394248
M166138310361467101082981097913030177914201085238189814132112252912119575747130380250
N4017611379183868363210136353802248921938108528613677243919252091301529711259440250
O4717157265227343412619126027862714547923828629665745313892291583143659627
P297157914181242470104010181098154331911136318981367296111255152820611665801011141377243
Q51424184113963250151476110123016510222
R483140711177549956782914107938734481632711321243957412551248062173447591885205613250
S953112718321097921231037119412155253209291876122519255311528304806312632761788723226216540
T45313441783234817341121151414533313461340204929122091389206116217331262566821187215602429
U28987412010718935710381267117128611930122911660447327256434161523912
V5239841854987387373239421253795995755295858055916176824335396142154
W2018368167262916206698052001965178997477113141011108858871187416353108400136
X547015313557301303423711914213025936141220523221515961087458
Y585366274616216220337135611181362733943804405963772613262160223914240074108
Z301512093075789180137286618024825025027243225065404291215413658108

As you can see, the letters involved in typos that are genuine words are also the most common letters -- except C and P. (The frequency values are on an arbitrary scale to match the typo figures.)

Then I wrote a Python routine to generate a 'badness' score for each layout, which is the total number of words you can make by replacing a letter of another word with one of the six keys adjacent to it. Running it on 10,000 random layouts, the average badness is around 83,603, with a standard deviation of 14,024.

Here are some other layouts I tried:

LayoutBadnessSTDs above mean
Qwerty119,1702.54
Dvorak121,4582.70
Colemak112,3542.05
Best random46,414−2.65
Worst random151,4384.84
Alphabetic74,064−0.68
Best I found31,992−3.68

(Predictable answer to question in title: "haha, no".) Alphabetic uses the same key layout as Qwerty: 10 on the top row, 9 on the second and 7 on the bottom. The 'best I found' layout was derived from a random board on that Qwerty grid (since actually Dvorak and Coleman don't really fit on a phone), by swapping letter pairs at random and keeping the change if it seemed to work. (This is called a 'genetic algorithm', albeit a crude one.) I think I did 5,000 steps, five or six times. Here's the layout it found:

DWE BKR ITQS
  OJV UZF XAM  
  CLG HNY P  

The most obvious thing it's done is put S (the most typoable letter) in a corner and shoved Q up against it. Another potential improvement to the model is to account for second-nearest neighbours -- since flagging an error but correcting it to the wrong thing isn't much better than missing it.

Another thing it's done is put all the rarest letters in the middle where they have lots of neighbours -- almost precisely the opposite of what Dvorak and Coleman did. Which makes sense, both intuitively and because all the standard layouts are in the worst 5% of all layouts (assuming normal distribution).

Anyway, I think we can all agree this is plainly the best possible keyboard layout for smartphones, and we should name it Taylak and petition Apple and Google to include it as the default for everything ever. I certainly can't imagine how using the same layout on phones and computers could possibly be more desirable than this.

Here, to end on, is the worst layout I could find, with 204,290 = μ + 8.61σ possible real-world typos:

VNT MBG EIJQ
  ZSD PCK AOX  
  YRL FHW U  

Nobody use that layout.

This article is my 2984th oldest. It is 801 words long