megi's PinePhone Development Log RSS

2021–07–26: The latest Pinephone keyboard prototype

The last prototype arrived today, so I uploaded my firmware to it and tested it. It looks good! There are no shorted or interrupted columns and rows this time, the two PCBs were merged into one, and all keys are easy to press and react well. Even spacebar now reacts to key press along all it's surface.

(„stuck“ keys is just some issue with debugging USB interface code I'm using, some reports don't get through)

There's one thing that I didn't realize before though…

Phantom keys

My original enthusiasm about being able to register arbitrary key combinations has to be tempered a bit by reality. :)

The general issue with matrix keyboards can be described like this:

If you press 3 keys in this specific pattern on the matrix (electrically), the fourth corner of the box pattern will also appear as shorted, because it's specific column and row wires are shorted electrically via the other three keys. I think this is called a phantom key, and is a general problem of keyboard matrices.

Here is the illustration of the issue on the real keyboard:

It's worked around by placing typical modifier keys on separate columns and rows:

The rest of the keys are placed on the matrix in such a way, that pressing Ctrl+Alt+Shift and one other regular key will not create any phantom key effect. And when it does, the phantom key is on the unused combination of the row and column, so it can be ignored.

This makes it so, that you can use modifier keys freely, without ever noticing this fundamental issue. In fact, I haven't noticed this on normal PC keyboards in the last 20 years. But they have the same issue!

For example I can't press C+V+G on my desktop keyboard without the keyboard ignoring the last pressed key, whichever one it is. I never noticed, and I don't think I'll ever notice that again. :) Three letter combos are not common, except for government agencies.

And this is actually the workaround for the issue, too. The keyboard's software checks after each new pressed key, if the key would produce a phantom key effect, and if it would, it ignores both the actually pressed key and its phantom counterpart.

Of course this gets even more complicated if you press more than 3 keys, depending on which combo it is.


The above issue just has to be handled in the driver/userspace software. There's not much else that can be done.

I've checked the actual configuration of the pinephone keyboard matrix, and it is designed in such a way that you can use any combination of Ctrl+Alt+Shift + one other key (that is not Fn) safely.

Fn key is on the same row as Alt key, so you can't combine those two. You can combine Ctrl+Shift+Fn arbitrarily though.

You can also use any combination of any two keys on the keyboard.

Enter and Backspace keys are on their own column, so one of those can also be combined with any other safe key combination as described above.

So that's all rather good, in the end! :)

Some more photos


This is how to connect USB to flash the basic firmware over USB. Some rather easy soldering:

(Final version will allow flashing over I2C.)

Next steps