What’s your type? The Maths behind the ‘Qwerty’ Keyboard

The maths behind the most unshakeable technology of the 20th century

Martha Bozic

In 1867, a newspaper editor in Milwaukee contemplated a new kind of technology. He had previously patented a device which could be used to number the pages of books but, inspired by the suggestions of fellow inventors, he decided to develop it further. The idea itself wasn’t exactly new – it had been echoing around the scientific community for over 100 years. The challenge was to realise it in a way that was commercially viable, and Christopher Latham Sholes was ready.

His first design, in 1868, resembled something like a piano. Two rows of keys were arranged alphabetically in front of a large wooden box. It was not a success. Then, after almost 10 years of trial and error came something much more familiar. It had the foot-pedal of a sewing machine and most of the remaining mechanism was hidden by a bulky casing, but at the front were four rows of numbers, letters and punctuation… and a spacebar.

Surprisingly little is certain about why he chose to lay it out as he did, probably because to Sholes the layout was no more than a side-effect of the machine he was trying to create. But as the most influential component of the typewriter, the qwerty keyboard has attracted debates about its origin, its design and whether it is even fit for purpose. Without historical references, most arguments have centred on statistical evidence, jostling for the best compromise between the statistical properties of our language and the way that we type. More recently, questions have been posed about how generic ‘the way that we type’ actually is. Can it be generalised to design the perfect keyboard, or could it be unique enough to personally identify each and every one of us?

The first typewriter was designed for hunt-and-peck operation as opposed to touch typing.  In other words, the user was expected to search for each letter sequentially, rather than tapping out sentences using muscle-memory. Each of the 44 keys was connected to a long metal typebar which ended with an embossed character corresponding to the one on the key. The typebars themselves were liable to jam, leading to the commonly disputed myth that the qwerty arrangement was an effort to separate frequently used keys.

Throughout the 20th century new inventors claimed to have created better, more efficient keyboards, usually presenting a long list of reasons why their new design was superior. The most long-lasting of these was the Dvorak Simplified Keyboard, but other challengers arrived in a steady stream from 1909, four years after qwerty was established as the international standard.

Is it possible that there was a method behind the original arrangement of the keys? It really depends who you ask. The typebars themselves fell into a circular type-basket in a slightly different order to the one visible on the keyboard. Defining adjacency as two typebars which are immediately next to each other, the problem of separating them so that no two will jam is similar to sitting 44 guests around a circular dinner table randomly and hoping that no one is seated next to someone they actively dislike.

Picture 1
The qwerty keyboard and typebasket (Kay, 2013)

For any number, n, of guests, the number of possible arrangements is (n-1)!. That is, there are n places to seat the first guest, multiplied by (n-1) places left to seat the second guest, multiplied by (n-2) for the third guest and so on. Because the guests are seated round a circular table with n places, there are n ways of rotating each seating plan to give another arrangement that has already been counted. So, there are (n x (n-1) x (n-2) x…x 1)/n = (n-1) x (n-2) x…x 1 arrangements, which is written (n-1)!.

By pairing up two feuding guests and considering them as one, you can find the total number of arrangements where they are sat next to each other by considering a dinner party with one less person. From our calculation above we know the total number of possible arrangements is (n-2)!, but since the feuding pair could be seated together as XY or YX we have to multiply the total number of arrangements by two. From this, the final probability of the two feuding guests being sat together is 2(n-2)!/(n-1)! = 2/(n-1), and so the probability of them not being sat together is 1-(2/(n-1)) = (n-3)/(n-1).

But what if one or more of the guests is so unlikable that they have multiple enemies at the table? Say ‘h’ who has been known before now to clash with both ‘e’ and ‘t’. Assuming the events are independent (one doesn’t influence the other) we just multiply the probabilities together to get the chance of ‘h’ being next to neither of them as [(n-3)/(n-1)]2. And the probability that on the same table ‘e’ is also not next to her ex ‘r’ is [(n-3)/(n-1)]2 x [(n-3)/(n-1)] = [(n-3)/(n-1)]3. So, for any number of pairs of feuding guests, m, the probability of polite conversation between all is [(n-3)/(n-1)]m.

Now, returning to the problem of the typebars, a frequency analysis of the English language suggests there are roughly 12 pairings which occur often enough to be problematic. For n=44 symbols, the dinner party formula gives a probability of [(44-3)/(44-1)]12 = [41/43]12 = 0.56. That is a better than 50% chance that the most frequently occurring letter pairs could have been separated by random allocation. An alternative theory suggests that Sholes may have looked for the most infrequently occurring pairs of letters, numbers and punctuation and arranged these to be adjacent on the typebasket. The statistical evidence for this is much more compelling, but rivals of qwerty had other issues with its design.

August Dvorak and his successors treated keyboard design as an optimisation problem. With the advantage of hindsight now that the typewriter had been established, they were able to focus on factors which they believed would benefit the learning and efficiency of touch typing. Qwerty was regularly criticised as defective and awkward for reasons that competing keyboards were claimed to overcome.

The objectives used by Dvorak, qwerty’s biggest antagonist and inventor of the eponymous Dvorak Standard Keyboard (DSK), were that:

  • the right hand should be given more work than the left hand, at roughly 56%;
  • the amount of typing assigned to each finger should be proportional to its skill and strength;
  • 70% of typing should be carried out on the home row (the natural position of fingers on a keyboard);
  • letters often found together should be assigned positions such that alternate hands are required to strike them, and
  • finger motions from row to row should be reduced as much as possible.
Picture 2
The Dvorak Simplified Keyboard (Wikimedia commons)

To achieve these aims, Dvorak used frequency analysis data for one-, two-, three-, four- and five- letter sequences, and claimed that 35% of all English words could be typed exclusively from the home row. He also conducted multiple experiments on the ease of use of his new design over qwerty, although the specifics were sparsely published.

Of course, however good Dvorak’s new design may have been, there was a problem. Qwerty being pre-established meant that finding subjects who were unfamiliar with both keyboards was difficult. Participants who tested the DSK had to ‘unlearn’ touch typing, in order to relearn it for a different layout, while those using qwerty had the advantage of years of practice. The main metric used to determine the ‘better’ design was typing speed but clearly this was not only a test of the keyboard, it was also a measure of the skill of the typist.

Alone, average typing speed would not be enough to distinguish between individuals – any more than 40 words per minute (wpm) is considered above average and since a lot more than 40 people are average or below average typists, some of them must have the same wpm – but other information is available. Modern computer keyboards send feedback from each letter you type, leading to a wealth of data on the time between each consecutive key press. This can be broken down into the time between any particular letter pairing, building a profile on an individuals specific typing patterns, and combined with typing speed it is surprisingly effective at identifying typists.

In a battle of the keyboards, despite its suboptimal design and uncertain past, qwerty has remained undefeated. Today it is so ubiquitous that for most people to see a different layout would be jarring, yet our interactions with it are still identifiably unique. Nearly 150 years after its conception, the keyboard is embedded in our culture – it’s an old kind of technology, just not the one Scholes thought he was inventing.

Oxplore Live: What’s your biggest BIG question?

A very special Oxplore livestream as I’m joined by 3 Oxford undergraduates to discuss the biggest of BIG questions in celebration of Oxplore turning 50. Featuring gems such as ‘can we develop artificial intelligence without it controlling us?’, ‘what would happen if al of humanity were immortal?’ and ‘what was the best era or time period for humans to live in?’ Watch the video below and join in the discussion @letsoxplore.

Tom Crawford, and Rockin’ Maths Matters

Esther Lafferty meets Dr Tom Crawford in the surprisingly large and leafy grounds of St Hugh’s College Oxford as the leaves begin to fall from the trees. It’s a far cry from the northern town of Warrington where he grew up.

Tom is a lecturer in maths at St Hugh’s, where, defying all ‘mathematics lecturer’ stereotypes with his football fanaticism, piercings, tattoos, and wannabe rock musician attitude, he makes maths understandable, relevant and fun.

‘It was always maths that kept me captivated,’ he explains, ‘ever since I was seven or eight. I remember clearly a moment in school where we’d been taught long multiplication and set a series of questions in the textbook: I did them all and then kept going right to the end of the book because I was enjoying it so much! It was a bit of a surprise to my teacher because I could be naughty in class during other subjects, messing around once I’d finished whatever task we’d been set, but I’ve loved numbers for as long as I can remember and I still find the same satisfaction in them now. There’s such a clarity with numbers – there’s a right or else it’s wrong. In English or History you can write an essay packed with opinion and interpretation and however fascinating it might be, there are lots of grey areas, whereas maths is very black and white. I like that.’

‘My parents both left school at sixteen for various reasons but they appreciated the value of education. My mum worked in a bank so she perhaps had an underlying interest in numbers but it wasn’t something I was aware of. I went to the local school and was lucky enough to be one of the clever children but it wasn’t until I got my GCSE results [10 A*s] that the idea of Oxford or Cambridge was suggested to me. I would never have thought to consider it otherwise.

‘I remember coming down for an interview in Oxford, at St John’s, arriving late on a Sunday night and the following morning I took a stroll around the college grounds  – I could feel the history and traditions in the old buildings and it was awesome. I really wanted to be part of everything it represented. I thought it would be so cool to study here so I was very excited when I was offered a place to read maths.

‘Studying in Oxford I found I was most interested in applied maths, the maths that underpins physics and engineering for example. ‘Pure’ maths can be very abstract whereas I prefer to be able to visualise the problems I am trying to solve and then when you work out the answer, there’s a sudden feeling when you just know it’s right.’

In his second year, Tom became interested in outreach work, volunteering to take the excitement of maths into secondary schools under the tutelage of Prof Marcus Du Sautoy OBE as one of Marcus’s Marvellous Mathematicians (or M3), a group who work to increase the public understanding of science.

‘I went to China one summer to teach sixth formers and it was great to have the freedom to talk about so many different topics. I spent another summer in an actuary’s office because I was told that was the way to make real money out of maths – it was a starkly different experience. I realised I was not at all cut out for a suit and a screen!’ Tom smiles. ‘I am a real people-person and get a real buzz from showing everyone and anyone that you can enjoy maths, and that it is interesting and relevant. I love the subject so much and I think numbers get a bad press for being dull and difficult and yet they underpin pretty much everything in the whole universe. They can explain almost everything and you’ll find maths in topics from the weather to the dinosaurs.

Take something like the circus for example – hula-hoops spinning and circles in the ring, and then the trapeze is all about trigonometry: the lengths and angles of the triangle. Those sequinned trapeze artists are working out the distances and directions they need to leap as they traverse between trapezes and its maths that stops them plummeting to the floor!’

Having spent four years in Oxford Tom then spent five years at Cambridge University looking at the flow of river water when it enters the sea, researching the fluid dynamics of air, ice and water, and conducting fieldwork in the Antarctic confined to a boat for six weeks taking various measurements in sub-zero temperatures. You’d never expect a mathematician to be storm-chasing force 11 gales in a furry-hooded parka, but to get the data needed to help to improve our predictions of climate change, that was what had to be done!

Tom also spent a year as part of a production group known as the Naked Scientists, a team of scientists, doctors and communicators whose passion is to help the general public to understand and engage with the worlds of science, technology and medicine. The skills he obtained allowed him to kick-start his own maths communication programme Tom Rocks Maths, where he brings his own enthusiasm and inspiring ideas to a new generation alongside his lectureship in maths at St Hugh’s.

A keen footballer (and a massive Manchester United fan) it’s no surprise Tom has turned his thoughts to football and as part of IF Oxford, the science and ideas festival taking over Oxford city centre in October, Tom is presenting a free interactive talk (recommend for age twelve and over) on Maths versus Sport – covering how do you take the perfect penalty kick? What is the limit of human endurance – can we predict the fastest marathon time that will ever be achieved? And over a 2km race in a rowing eight, does the rotation of the earth really make a difference? Expect to be surprised by the answers.

Esther Lafferty, OX Magazine

The original article can be found here.

Oxplore: Do we see colour the same?

Livestream debate with researchers at the University of Oxford discussing the BIG question: do we see colour the same? Featuring an incredible trick with colour perception, a multiple choice question for you to try at home, and a discussion of the dress – is it blue and black or white and gold?

The Tragic History of Mathematicians

The second puzzle in the new feature from Tom Rocks Maths – check out the question below and send your answers to me @tomrocksmaths on Twitter, Facebook, Instagram or via the contact form on my website. The answer to the first puzzle can be found here.

Below are portraits of four famous mathematicians from history that have all died in tragic circumstances. Your task is to match up the mathematician with one of the following causes of death:

  • Shot in a duel
  • Pushed overboard from a ship
  • Suicide
  • Lost his mind

Bonus points for explaining the work of any of the mathematicians shown. Good luck!

WARNING: answer below image so scroll slowly to avoid revealing it accidentally.



a. Hippasus – Pushed overboard from a ship for his discovery and subsequent proof that the square root of 2 is an irrational number (cannot be written as a fraction).

b. Cantor – Lost his mind after discovering that there are more one type of infinity. For example the positive integers (whole numbers) are countably infinite, whilst the real numbers are uncountably infinite.

c. Boltzmann – Suicide. He is most famous for the development of statistical mechanics which explains how the properties of atoms determine the physical properties of matter.

d. Galois – Shot in a duel after being involved in a ‘love triangle’. Fortunately he wrote down all of his work/thoughts the night before which now forms the basis of Galois theory.


Up ↑