- I spent 100 days typing with the worst keyboard
on the planet, with its characters rearranged
by artificial intelligence
to cause me as much pain as possible.
Along the way, I learned how QWERTY came to be,
some of the pitfalls of optimization,
and I even got a bit better at typing.
However, this was still a terrible idea.
(typewriter clacking)
I've always wondered why our computer keyboards
follow the QWERTY layout,
rather than something more logical, like maybe A to Z.
I had heard that it was to stop
old typewriter keys from jamming,
but that's not entirely correct.
If you could ever point to the world's first keyboard,
then this would probably be it.
It's called the Printing Telegraph,
and it was invented in 1846 by the Electrician, R. E. House.
Like with a regular Morse Code Telegraph,
it can send long distance messages along wires.
But unlike with Morse Code, which uses dots and dashes,
this one could send entire letters.
It's written out A to Zed,
which, yeah, sort of does make sense,
but is also incredibly inconvenient to use.
In 1855, pianist, David Hughes,
took advantage of people's familiarity with piano keyboards
to create this thing.
Effectively, it's the House Machine,
just folded in half.
The black keys are the letters A through to N,
and the whites, O to Z.
Now, the real thing didn't actually play music,
but if it could, then the sentence...
(playful music)
would sound a bit like that.
The next improvement came in 1868,
when engineers Sholes, Glidden, and Soule
took apart one of these Hughes Machines
to use as their foundation for their typewriter.
The rectangular piano keys were switched out,
for rounded buttons,
and the vowels pushed up to their own row.
Symbols were added in,
although the letters I and O were made to double up
as one and zero.
The keys were pushed together
and rows staggered to leave room for mechanical linkages.
In 1870, the trio tried to sell this design
to American Telegraph Works
as a way of allowing their operators
to transcribe messages rapidly.
As an added bonus,
the telegram would now actually be legible.
American Telegraph loved this design,
but asked for a couple of modifications
to make things even faster.
The letter I, moonlighting as the number 1,
was moved next to 8,
so that the year 1870 could be written rapidly.
In Morse Code, the letter Zed (Morse Code beeps)
is often confused with the sequence SE,
so those letters were moved close together.
Frequently used characters were pushed
to the easy to reach middle of row two.
While those used infrequently were moved to the edge.
The fact that you can now spell typewriter
using just the second row of a typewriter,
was of course, entirely coincidental.
Soon, other manufacturers copied this design,
reasoning that if people were familiar
with the Sholes layout,
then they'd probably want to have something pretty similar.
However, in order to avoid patent infringements,
they needed to mix around a couple of the characters.
Purely by accident,
someone accidentally invented the QWERTY layout
that today we know and love.
Eventually, an agreement between the major manufacturers
standardized things to QWERTY,
and more than 125 years later,
it's still being used on everything,
from laptops and smart fridges to the clicky clacky
desk candy of r/MechanicalKeyboards.
This process replicates what AI researchers like to call,
a Hill Climbing Algorithm.
We start out with a certain keyboard configuration
and then you as an innovator,
come along and make a small change.
If the change results in a worse keyboard,
then no one will buy it and your company
goes out of business.
However, if the change is beneficial,
then people will buy it and the next innovator
who comes along will make a small change
based on your improved keyboard design.
Like climbing a rail hill,
we only ever take steps toward the top.
And at the top of our keyboard hill is QWERTY.
Unfortunately, one of the problems
with this hill climbing approach,
is that by making small changes
and getting a constantly better solution,
sure we might be able to get to the top of a hill,
but chances are that there is an entire mountain
just over there which we can never reach,
because to get to that objectively better solution,
we first have to climb back down.
QWERTY isn't just suboptimal,
it might also, be actively dangerous.
I've got here a sort of heat map
with the blue and green keys the most popular,
and the reds, the least.
QWERTY shoves a lot of the popular keys up top,
which means that from their home position,
your fingers really have to stretch in order to reach them.
A lot of the stretching is diagonally
and your fingers and hands are being used super unevenly.
Your left middle finger is being used
way more than the right one.
With this in mind, it perhaps comes as no surprise
that keyboards cause nearly
half a million injuries per year in the US alone.
Most of these are from repetitive strain,
but also from that one guy in Kentucky
who attacked his neighbor with a typewriter.
Not much you can do about attack typists,
but given a blank slate, could we redesign QWERTY
to reduce these injuries?
And for that matter, could we make it so that it's
so egregiously awful it gives you arthritis
just by looking at it?
Only one way to find out.
To begin we'll need to define
what good and bad actually mean in the context
of keyboard design.
This is what machine learning engineers like
to call an objective function.
My first assumption is
that it's better if your fingers have
less distance to travel.
When you are typing out a letter, your fingers need to move
to their new position adding in a
certain amount of distance.
My second assumption is
that it's really annoying if the same finger has to move
to multiple keys in a row.
For example, typing out a full stop at the end
of Romeo means that your right ring-finger needs
to move from the O to the stop.
I also considered the relative annoyance
of using each finger, which I tested out by seeing
how many times each finger
could click its home key in a minute.
It turns out that my left ring finger
is really terrible at this,
and we'll see if that affects the
optimization results later on.
I've scaled each of these factors so
that they give an equal contribution to our final score
and I've scaled that score based on QWERTY.
Using these assumptions,
alphabetical order is 1% worse than QWERTY,
which makes sense given that QWERTY
is just alphabetical order
with a couple of keys mixed around.
Ortholinear, where the keys are vertically arranged
scores 0.3% better than staggered.
Which is actually remarkably small.
And because it's so hard to make
and get an ortholinear keyboard,
I've actually kept with staggered
with most of my optimizations.
Obviously, I'm not the first person
to try optimizing keyboard layout using science
and the most popular QWERTY alternative,
known as Dvorak, based on letter frequency,
gets a 26% improvement.
That's fantastic, but I think we can do better.
If you were to build
and then line up every single possible keyboard permutation,
then you form a row stretching from here in Boston
to New York City
and then around the observable universe 500 billion,
billion, billion times.
Rather than getting an unpaid, overworked, sleep-deprived,
caffeine addicted PhD student
to test out all those different keyboards,
another option is to get the computer to do that for you
with what's called machine learning.
Today, I'll be using a specific approach
known as simulated annealing,
which will hopefully prevent us from needing
to test out all of those different options.
In the world of material science,
annealing is when we heat up a metal
and then slowly cool it back down, which allows the atoms
to gradually rearrange themselves in a more optimal,
low-stress configuration.
We can apply this same concept to keyboards,
to slowly rearrange their keys
and relieve the stress from our fingers.
We start out with a random arrangement of letters
and numbers and a simulation temperature of 500 degrees.
It'll cool down later on, but 500 is where we start.
Based on this current temperature, we're going
to remove a certain number of keys since it's 500 degrees,
let's say that's five.
We then shuffle them out
and we put them back in.
In a completely new and randomized arrangement.
After our shuffle,
we compare the new keyboard to the old one.
If the new keyboard is better than the old one,
then we'll keep it and use it as the basis
of our next shuffle.
In this way, it's the same
as the hill climbing algorithm from earlier.
If on the other hand it's worse, then the genius
of the simulated annealing approach
is that there is a chance we'll still keep it anyway.
We tie this probability
with the current simulation temperature.
Near the start of the simulation,
when temperature is high, there's a high chance
that we'll keep a worse design.
Whereas near the end of the simulation,
when things cool down a bit,
then the chance of keeping a worse design is much lower.
Looking at this through the lens of hill climbing, it's
as if we explored the base of lots of different hills
but then only ended up climbing the tallest mountain.
I wrote this out in code
and had our objective function type out
all the works of Shakespeare.
At the start we have big swings in score
as we're accepting pretty much all the different keyboards,
even those that are definitely worse.
However, over time as the simulation cools,
we have a more consistent increase.
Although, still with the occasional dip back down.
After two days of simulation time, we've got it.
A keyboard that is 39% better than QWERTY at writing out
all the works of Shakespeare.
My right index finger has immediate access to the letter E,
as well as other popular characters
and my left ring-finger barely has
to do anything at all.
To get more insights,
I also looked at other classic pieces of literature,
like every single comment this channel has ever received.
The top 100 Wikipedia articles of all time,
and the script for the "Bee Movie."
This is our YouTube keyboard,
Wikipedia
and the "Bee Movie."
Like with the Shakespeare keyboard,
but unlike with QWERTY,
the popular keys are almost always in the home row.
Looking at finger frequency, you can see a definite bias
for using my stronger fingers.
Of course, the whole reason for using a keyboard
is to write actual words.
And it's here where we see the biggest improvement.
Frequently used words like "thee" in Shakespeare,
"internet" on YouTube,
"edited" with Wikipedia,
and "honey" in the "Bee Movie,"
all see significant improvements.
We can also play around with a couple of our assumptions.
If you're writing a YouTube comment,
then chances are you're on a phone
and optimizing for a 10 finger typing pattern
is actually a bit silly.
With just the thumbs,
this is what our digital keyboard should look like.
Optimizing for XY positions on the Wikipedia training set
gives us this mess.
AI has no respect for my joints.
All of this is great, but completely disregards the fact
that learning a new layout sucks.
To take this into account, I use the "Bee Movie"
to create what's called a Pareto frontier,
which indicates the best keyboard layout
for the minimum number of key changes.
If you can only make one switch,
then E and J gives a full 13% improvement
with basically no effort.
But if you're a little more daring,
then this eight key version gets you all the way
to a 31% improvement.
So we've got the code
and have run through its paces
in creating better keyboards.
But what if you want to make the world's worst?
Well, actually updating the code was remarkably simple.
I just changed a greater-than sign into a less-than sign.
However, I wanted to train on something
that's a bit more personal than just
all the works of Shakespeare.
How often do I have to write out that?
So instead, I took every single assignment
that I've ever submitted for university,
three years of email data,
and I just tracked my key inputs
for two weeks in order to create the greatest training set
of personal data that has ever been made,
and no, you are not getting a copy of it.
With a bit of training,
we get this,
the worst keyboard on the planet, if you happen to be me.
Writing on this thing isn't fun.
On the evening of the first day, my tendons were sore,
and after the first week,
my left wrist was actively painful.
Mentally too, it was a bit of a challenge,
and I could practically feel my neurons rewiring themselves.
Now, normally I'm pretty average at typing
at 60 words per minute,
but the new layout dropped me down to just six.
Over time, it did improve,
and I could get to about 30 words per minute at the end
of a hundred days, but it's still not great.
I think overall a good analogy would be like wearing gloves.
At the beginning, these were big, chunky gloves,
making it really hard to type,
but over time, my brain could mostly compensate
and writing became a bit more natural.
There were exactly two benefits to this new arrangement.
First, finding the key you're looking for is super easy
because all the popular characters are exactly
where your fingers aren't.
Another benefit is
that it really gave my weaker fingers a workout.
Normally, I prioritize just my pointer and middle finger,
but now the others were being used as well.
It's been a hundred days and I'm back to QWERTY
but now I type using my entire hand.
My left ring-finger still sucks,
but just that little bit less.
At the end of the day,
would I recommend fully optimizing your own keyboard?
No. Learning the remapping is incredibly painful.
Did I leave a copy of the code in the description
anyway for you to try yourself?
Yeah, of course I did. Let me know how it goes.
In the meanwhile, I created an entirely edible,
bird-safe version of the world's worst keyboard,
which I'm very much looking forward
to throwing into the Charles.
Perhaps the geese can find a better use for it.
This has been James Dingley from the Atomic Frontier.
Keep looking up.
(light music)
Feast, my child!