A project log for All About Laptop Keyboard Reuse

Reverse-engineering laptop keyboards: theory, hardware, and sharing data

aryaArya 06/07/2022 at 04:070 Comments

A laptop keyboard is a diode-less key matrix. Its keys are distributed in a way that you can press the most important key combinations at once, despite the lack of diodes - to the point where some rows only contain one or two keys.

Often, there's also LEDs for functions like WiFi status, CapsLock and NumLock inside the keyboard, connected to the same FPC connectors. If there's backlight inside the keyboard, it's typically connected separately, however. Sometimes, there's a power button on the keyboard - then, it's also available on the same FPC.

Laptop keyboards typically use 0.8mm pitch FPC connectors, and 1mm connectors were typically used in older laptops. For small and modern laptops, it's not unheard of to use 0.5mm connectors. At times, keyboards use proprietary connectors, sometimes exposing all the signals through them (i.e. Framework or Thinkpad) and sometimes using a separate keyboard controller chip on a sub-board, which uses some kind of low-pin-count interface to talk to the EC (i.e. Dell Latitude E7470).

Typically, there's 8 rows and 16 columns in a keyboard matrix - this helps the EC scan the keyboard, since 8 and 16 are multiples of 8, and it's a bit easier to write code that operates with these. Numpad-equipped laptop keyboards tend to have 18 columns. There's no real difference between "rows" and "columns" - it's just a matrix of keys, either of the two sides can be called by either term, theoretically. For consistency, I use "columns" for the side which uses more GPIOs (so, typically the 16-pin side), since that somewhat represents how keyboards actually look physically - they have few rows and many columns.

As implied in the first paragraph, the key arrangement in the matrix doesn't represent the physical arrangement of the keys on the keyboard. In fact, it's quite a bit different. For a laptop keyboard, you need to be able to press certain keys simultaneously, i.e. Shift/Ctrl/Alt+KEY combos, and Ctrl+Alt+Delete. Laptop keyboards don't use diodes, however - they compensate by dedicating entire columns to certain keys. This explains why a typical keyboard can technically have 128 or 144 spots for keys (8x16 or 8x18), but has way less keys available, typically, from 80 to 100.

[TODO: image]

While scanning the matrix, some GPIOs have to be set as outputs, and some have to be set as inputs. It's quicker to scan through 8 pins than it is to scan through 16 pins. So, "row" pins are typically referred to as KSI (Keyboard Scanning Input, 8 pins that are set as outputs on the EC), and "column" pins are typically referred to as KSO (Keyboard Scanning Output, 16-18 pins set as inputs on the EC). Again, some keyboards might use a different terminology, I haven't checked that - I chose this convention because it makes sense physically.