Author Topic: [BUILD] Magic Keyboard 2 but mechanical  (Read 13575 times)

0 Members and 1 Guest are viewing this topic.

Offline Limentic

  • Thread Starter
  • Posts: 12
[BUILD] Magic Keyboard 2 but mechanical
« on: Thu, 27 July 2023, 19:11:53 »
Hello Geekhack!
This topic was originally opened on the LTT forums, but I decided to move it here because it felt more appropriate.
Unfortunately, there wasn't much engagement on the thread over there, and I thought you guys, here, might be more interested in this project.
This post will bundle the two posts I made on the LTT forums into one. Shortly after this, I will post a new one with the latest updates.

(Post 1)
Hi guys!

I'm Nathan, a French back-end software engineer by day and electronics enthusiast by night. Currently, I'm in the process of reverse engineering the new Magic Keyboard 2 from Apple.

You might say:

> Yeah, but for what? That's just silly and a waste of time...

Well, I want to transform the Apple Keyboard into a mechanical keyboard.
I plan to dismantle the entire keyboard, keep the main logic board, reverse engineer the matrix and other components, create my own PCB, connect it to the Apple board, and voila! A Mechanical Magic Keyboard is born. Or as I like to call it, the Magicanical Keyboard (funny, right?!).

> Ok, fine, but I still think this is silly. Couldn't you just build a Bluetooth board and call it a day?

And I would answer:

> Nooo!!

These new keyboards come with a built-in fingerprint sensor, known as Touch ID. As a Mac user (you can boohoo me if you want), both at home and work, I frequently use docked Macbooks. So, having a keyboard that is seamlessly integrated into the Apple ecosystem with easy pairing, Touch ID, battery indicator built into the OS, and more would be fantastic!

Here's a rundown of the tasks that need to be done: (Done ✅, To do ❌) (Updated 2023-10-05)

- Teardown the keyboard ✅
- Figure out the functionality of each component ✅
- Determine how the keys are connected to the microcontroller (whether it's a standard scanning matrix or something else, considering it's Apple after all...) ✅
- If it's a standard scanning matrix, understand how key presses are detected (whether the matrix is resistive or capacitive) ✅
- Plot each key's row and column ✅
- Create a development board to verify the theory ✅
- Debug/test the development board to ensure everything is functioning correctly ✅
- Search for a keyboard case that can accommodate my custom board
    - If I can't find what I want, design one from scratch ✅
- Determine how to fit the Touch ID sensor into a keycap ✅
    - If I can fit it inside a keycap:
        - Reverse engineer how the button under the Touch ID sensor is connected to the main board. ✅
    - If I can't fit it inside a keycap:
        - Figure out where I can fit this sensor!

- Create the final board and custom flex PCBs to go with it ❌
- Find macOS keycaps ❌

If I have time, here are some additional cool things I'd like to do:

- Replace the lightning connector with USB-C ❌
- Add per-key backlighting with a sleep timer
  (This would require in-depth reverse engineering of the Apple board, so it may not be doable)

> Okay, that seems like an interesting idea... When you're finished, could I replicate the project?

Absolutely! The project will be fully open-sourced when it's completed.

So, are you pumped for this? Let's get started!


1) Tearing down this bad boiii

I got this second-hand keyboard from LeBonCoin (the french equivalent of Craigslist), for 70€.
It was essential for me not to destroy a brand new keyboard, and if you decide to replicate this project in the future, I hope you'll consider using a second-hand keyboard (ones with spilled coke and sticky keys are perfect! 😛).
I'm passionate about making the world as sustainable as possible, so repurposing broken keyboards is the way to go!

Mine came with a broken key (damaged scissor mechanism and missing a keycap).

Front of the magic keyboard:


The back:


Removing the plastic rear cover was a NIGHTMARE. It took about an hour and a half and two bloody fingers to remove it! The surface was covered with a lot of glue, so I had to use a trusty hair dryer, guitar picks, a box cutter, and an old fidelity card to remove it.

Here's the "lot of glue":


If you decide to tear down your own keyboard, be careful not to insert your prying tools between the back cover and the plastic reinforcement plate. Instead, insert them between the back cover and the plate.

Here's a picture to illustrate what I'm talking about:


After applying heat, cutting the glue, and gently pulling the cover to avoid breaking it, I thought I could proceed with the reverse engineering without damaging anything. Silly me! 😄

The backing was finally off, and I needed a coffee break at that point. 😅

Yes, I know some screws are missing in the picture, but my camera decided not to focus properly. This is the only clear shot I have of this step.

Next, I removed all the small torx screws, disconnected the battery, and the plastic frame was finally free. And boom! We finally arrived at the interesting parts—the electronics!

Let's take an overview of what's going on here:


Now, let's try to remove the logic board from the chassis, and here's where the trouble began (unfortunately, I didn't have much footage of the following parts).

While attempting to remove the sticky tape from the keyboard matrix connector, I accidentally broke the upper part of the connector. At that moment, I naively thought:



But that wasn't the end of it! The back of the ribbon that plugs into this connector was covered in double-sided tape, which I didn't know at the time. When I tried to remove it without heating up the tape, I broke a small plastic bit that locks the connector. 🤦‍♂️


Here's what it looked like afterward:


Well, it seems I'll need to replace this connector now. Or maybe not. We'll see. Perhaps I'll just solder a flex cable directly to the main board.

Now that all the components are extracted from the chassis, I still don't have access to my matrix. At this point, it's time to bring out the big guns!

I need to remove the little plastic film that is glued to the aluminum frame. I believe this is to prevent crumbs, water, or any other debris from entering the keyboard.

To get this structural layer out of the way, I tried to create a lever using my small flat screwdriver at the solder points.


And it worked! After peeling away all that aluminum, we finally reach our goal. Here's a reconstruction of what it looked like:

It appears to be a basic keyboard matrix with rows and columns, without any Apple shenanigans involved!

The plastic matrix!

> Yeah, this project is going somewhere!!!


2) Let's take a closer look at this matrix


As we can see in the previous picture, it appears to be a classical resistive membrane keyboard.

Here's a schematic of how it works (Courtesy of Deskauthority):

Source: https://deskthority.net/wiki/Membrane_keyboard

The dome puts pressure on the top membrane, which deforms it and makes contact with the bottom membrane, completing the circuit. So, in theory, all I need to do to make it work is to figure out where each key connects to the 40-pin connector we saw earlier. And that's exactly what I've done!


"Thanks, Apple, for this choice. If the matrix were capacitive, I would have killed the project. In that case, I would need to delve deep into the Apple mainboard electronics and firmware to figure out what's going on and buy a fancy ESR meter to measure the precise change in capacitance when a key is pressed."


3) Tracing the connections

To identify the location of each key on the matrix, I scanned the matrix using my printer.


There was a small problem: the area where the pins are exposed is not translucent, so I couldn't determine where each pin goes. Luckily, Apple used tape for the reinforcement, so with the tip of a razor blade, I could peel it off.

That's better!

Before proceeding with the entire process, let's test our previous theory by simulating a "1" keypress.
I traced the two pads back to their respective pin on the matrix, masked every pin that was not the two I wanted to bridge on the connector, and bridged them using a male-to-male DuPont cable. AND IT WORKED!

(Once again, a reconstruction of what I did at that point)


An army of "1"s started appearing on my screen!

Now, after letting my sanity slip away for hours on end, I traced every trace on this flex board...

And ended up with this magnificent wallpaper!


I was so proud of myself at that point... but a crucial part was still missing...
I needed to plot each matrix position on a spreadsheet. sigh

So that's what I did... and now I can attempt to replicate it on a custom development/validation board.

But that will be for next time...

(Post 2)
Welcome back!

A lot of progress has been made since the last post, and the project is still going strong!

First of all, here's a table showing the two pins for each key.

I'm including this table because I realized it was missing before.

To validate my reverse engineering work before making the final PCB, I've created a development board to reproduce the matrix.

To get a rough idea of the voltage of the CAPS lock LED, I measured it with my multimeter, and it showed around 3.2V.

This was my first time using KiCad, and I switched from Eagle due to the recent changes in Eagle's payment scheme. KiCad's free and open-source nature, along with its strong community recognition, convinced me to switch.

So here's the schematic:

I didn't connect CAPS_LOCK_LED_- to ground because it doesn't seem to be connected.

As you can see, I've done my reverse engineering work on a French Magic Keyboard, and it seems that this work will be compatible with all magic keyboards that have 88 keys—heck, even the 87-key one. After carefully examining every layout on Apple's website, I noticed that only the US and Chinese versions have one less key. It's likely that Apple initially designed the 88-key layout and then removed a key from the matrix for the US and Chinese keyboards.

What's even more intriguing is the similarity I noticed in the connectors on both motherboards—the full-size one and the ten-key-less (TKL) one. Although I haven't reverse-engineered the larger keyboard, I speculate that Apple might have taken the matrix from the bigger keyboard and removed unnecessary keys to create the TKL version.

Considering both connectors have 40 pins and look identical between the full-size and TKL versions, it's reasonable to assume that the matrices might be the same across both keyboards. On my TKL board, I observed several pins on the connector being connected to ground, indicating unused connections. This similarity and the presence of unpopulated pins support the notion that the matrices are likely the same across both the full-size and TKL versions, regardless of the regional layout.

If you closely examine both boards, you can see the same connector on both the TKL and full-size one (Picture courtesy of SnazzyLabs).

Source: https://www.youtube.com/watch?v=hz9Ek6fxX48

For the curious ones among you the connector is the FF14A -40C -R11DL-B-3H from DDK.
https://www.ddknet.co.jp/English/products/print/fpc-connectors/ff14a/FF14A-C_ENG.pdf

After the schematic, here's the dev board layout:


For the FPC connector, I've used a random 0.5mm pitch connector from the KiCad library.

You might ask:

> Why did you put four plated holes for each key? A switch only needs two...

Yeah, you're right, but I added the extra plated holes because I want to put dupont male headers on the top two pins and use a dupont cable with a diode to try to find the "direction" of the matrix.

If I can figure out which pin is the row and which pin is the column, I could add a diode to each key to prevent key ghosting from happening at the hardware level. Though I suspect Apple might have used a fancy algorithm to avoid that at the firmware level or simply limited the number of keys that can be pressed simultaneously. I haven't tested that yet before tearing down the keyboard.

Now it's time to send those boards to PCBWay and wait for them to arrive.

Stay tuned for the rest of the project!
« Last Edit: Thu, 05 October 2023, 17:00:01 by Limentic »

Offline Limentic

  • Thread Starter
  • Posts: 12
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #1 on: Thu, 27 July 2023, 19:13:28 »
Hello again! :)
Here's the second post I was talking about in the first post.
This one isn't a repost from LTT forums but a brand new one, with new updates on the project.

A few days ago, I received my PCBs from PCBWay, and I was really, really excited! (I was supposed to receive them a day earlier, but the classic "I wasn't at home when DHL wanted to deliver the parcel" situation happened, so I had to wait another day...)


> Pretty, right?!

Immediately, I wanted to test the PCBs, but the ribbons I ordered from Amazon hadn't arrived yet.

A day later, the ribbons finally arrived, and I thought to myself, "What if, instead of removing my broken matrix connector and soldering the ribbon directly to the motherboard, the connector is still good enough to make a connection with a ribbon cable?"

I had three reasons for this:
- First, I couldn't find the connector ANYWHERE on the internet... (I searched for a few hours, but nothing...) The only website I could find them on wanted me to buy a full reel of 5000 pieces... (I don't need that many... nor do I have the money for it)
- Second, I didn't want to remove the connector because I was afraid it would further damage the motherboard...
- Third, I didn't want to solder the ribbon directly to the motherboard because I didn't think the ribbons could handle the heat of the soldering iron... (And I was right; I tried putting solder on the ribbon, and it melted instantly...) I know I could order special ribbons with polyimide from Aliexpress, but I didn't want to wait another month to receive them...

So, here goes nothing...

After playing with the connector (breaking it even more) and the ribbon, I finally managed to align them and make a connection between the two! Hurray!

No soldering required! And no need to wait for the polyimide ribbons to arrive! I was so happy!


> First time the CAPS LOCK LED lit up! But the connector still wasn't aligned properly... Keypresses weren't registered...

> Difficult to do better :D That's spot on!

I'm going to epoxy or hot glue that connector during the final assembly, but for now, that's good enough!

As you can see in the first picture, for each key, two male dupont headers are present, and there are two empty plated holes below each one. I did this because I wanted to plug dupont cables from my dev board into my breadboard and use a diode to try to find the "direction" of the matrix.

The two cables from my breadboard, with the diode in between, plug onto the headers on my board, and using a piece of wire, I can touch the two plated holes to make contact and simulate a keypress.

But, it didn't work. The only diodes I had lying around were some cheap, no-name diodes I got with an electronic kit, and I think their internal resistance is too high. When I tried them, the keypresses weren't registered...

So I gave up. Maybe I'll buy low-resistance diodes in the future, but it's not a priority right now. After all, Apple didn't use them on the original keyboard. I know it's because it was a membrane keyboard, but still... Anyway, my keyboard is going to work without them, and I could revisit this in the future if I want to.

So, I tested all my keys, and 9, TAB, and Option Right keys weren't registering...

After a few minutes of checking my reverse engineering work on the matrix, I found that I made a mistake when writing the pins down on my spreadsheet.

After cross-checking with the original matrix, the correct pins for those keys are:
- 9: 30 and 1
- TAB: 7 and 22
- Option Right: 24 and 22

So, I corrected my spreadsheet, looked at my schematic on KiCad to see where those pins were located, and I tried to bridge them using a wire. Believe it or not, it worked!

I have fully and successfully mapped the matrix of the 88 key magic keyboard! I was so proud of myself; I had spent a lot of hours on this, and it finally paid off!


> First time all keys working! (Sorry for the quality of the picture; it's a screenshot of a video I made to show my friends; it's the only picture I have of this moment...)
Now, it's time to tackle the Touch ID part! But that will be for another post!

I'm taking this opportunity to ask if someone knows where I could find a cheap plastic case that will fit the layout I've designed for this keyboard. Who knows, if it avoids me making a custom one, that would be great. Even if I don't think I'll be able to use a standard one, because I would need a lot of special mounting brackets for all the bits of the magical keyboard, but hey, who knows...

Here's the layout:
« Last Edit: Thu, 27 July 2023, 19:21:29 by Limentic »

Offline Findecanor

  • Posts: 5040
  • Location: Koriko
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #2 on: Fri, 28 July 2023, 01:27:13 »
Impressive amount of work!
I take it that your custom PCB is only for prototyping and not going to be part of the final keyboard.

BTW, short right Shift keys in keycap sets are usually 1.75u.
🍉

Offline Limentic

  • Thread Starter
  • Posts: 12
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #3 on: Fri, 28 July 2023, 15:08:12 »
Impressive amount of work!
I take it that your custom PCB is only for prototyping and not going to be part of the final keyboard.

BTW, short right Shift keys in keycap sets are usually 1.75u.

Thanks, man, I appreciate it. ;)
Yeah, the custom PCB I've received is not for the final keyboard; it's just a development board. I recognize I didn't emphasize enough on that.
I'm going to build another custom PCB that matches the layout above. :)

As for the right shift key, I've gone with this size because I wanted to have a small gap between my arrow keys and the shift key. But yeah, if it facilitates the keycap purchase, I'm all for it.
Feel free to suggest other layouts or ideas to help me improve this design.

The only thing I want/need is to keep all the original keys of the Magic Keyboard!

Offline PlayBox

  • Posts: 199
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #4 on: Mon, 31 July 2023, 14:10:34 »
just glanced over the thread but this does look cool.
propably sent from my amazon kindle 10th gen

Offline Havattack

  • Posts: 723
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #5 on: Sat, 05 August 2023, 16:23:16 »
Your'e a cool guy, and you do cool things.

I am impressed.

Offline Limentic

  • Thread Starter
  • Posts: 12
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #6 on: Wed, 16 August 2023, 06:26:13 »
Thank you, everyone, for the support! It truly boosts my motivation to keep pushing forward with this project :D

I apologize for the lack of progress this month. I've been busy preparing for my move, which is scheduled for the end of this month. I anticipate that I'll be able to resume work at the beginning of September.

Now, I've got a question for you all. Does anyone know how I can import this AutoCAD drawing to the Cu.F layer in the KiCad footprint editor?


I've managed to successfully import the outline of the FPC, but I'm currently facing challenges with the pins.


My goal is to replicate the Touch ID FPC. This replication will allow me to create a custom flex PCB, which in turn will aid me in reverse engineering the ribbon that connects the motherboard to the sensor. Additionally, I'm aiming to determine the connection of the tactile button beneath the Touch ID sensor on that ribbon, if such a connection exists.

Thanks in advance, guys, for any answers you provide ;)

Offline HeuristicBishop

  • Posts: 4
  • Location: New York
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #7 on: Mon, 28 August 2023, 17:15:14 »
Hey @limentic
Good to see I’m not the only one who wants to do silly things.
Over the past couple weeks I’ve done much of the exact same work on my Apple Magic Keyboard (non-touch)

My goal is a little different, I actually want to *remove* the Apple controller and hook the matrix up to a custom microcontroller (probably a kb2040 or similar)
Two sides of the same coin it seems  ;D

My approach to mapping the matrix was to hook up the matrix to a micro controller and snoop it as I pressed the keys. This generates a map of key to pin pair…in theory anyway. I should know for sure in the next week or so. Waiting on a microcontroller with enough gpio onboard so I don’t need to futz with expanders or anything like that. (I’ll share everything once it’s proven out)

How am I connecting the matrix to the controller? Good question!
I did a bit of surface mount rework to pull the (impossible to find) ribbon connector off and drop it on a 40pin idc breakout board.

I did not find this post before starting or I’d have tried to collaborate a bit. If I pick up a Touch ID board I’ll do some work to try and help you out with your quest 🙂

Let me know if you have any questions/comments or want me to work on anything specific. (Maybe a dedicated little pcb to adapt the Apple pinout to breakout for easier development 🤷‍♂️)
Good luck with the move!

Offline ItsPasi

  • Posts: 1
  • Location: Austria
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #8 on: Mon, 28 August 2023, 17:38:40 »
I also want to do the same as you @HeuristicBishop ^^

Problem with me is I have no knowledge of these things so when you are done with your project I hope you can help me out doing this myself.

Kind of awesome multiple people try to tinker around with this specific keyboard,

Offline Limentic

  • Thread Starter
  • Posts: 12
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #9 on: Sat, 02 September 2023, 05:26:52 »
Hello @HeuristicBishop! Apologies for the delayed response; I've been caught up with my move.

Hey @limentic
Good to see I’m not the only one who wants to do silly things.
Over the past couple weeks I’ve done much of the exact same work on my Apple Magic Keyboard (non-touch)
I did not find this post before starting or I’d have tried to collaborate a bit.
It's pretty crazy, isn't it? At least you've found my thread now! Your project is quite fascinating, and I believe you can leverage a significant portion of my work :D

Regardless of whether you're using an ANSI or ISO keyboard layout, the physical matrix appears to be the same. You can disregard the ">" key in my spreadsheet, and the rest of the data should still be applicable. I've conducted a quick test with a small program, and it confirms that the values in column A and column B are indeed distinct. In the context of building your controller, you can think of column A as what's checked by the MCU (the "rows"), and column B as what's pulled by the MCU (the "columns"). If you attempt to reverse engineer your keyboard matrix regardless, and if your keyboard region and layout differ from mine, I'm curious to see if your matrix differs from mine!

Here's the correct matrix:
KEYSCOL ACOL B
ESC727
F1326
F2726
F3826
F41726
F52126
F62926
F72526
F82826
F93026
F102427
F11327
F12319
#819
131
271
381
4171
5211
6291
7251
8281
9301
02327
°2127
_2919
BACKSPACE322
TAB722
A315
Z72
E816
R172
T2115
Y2915
U2515
I2815
O3015
P1127
¨2119
*1719
ENTER927
CAPS_LOCK1122
Q318
S713
D814
F1718
G2113
H2918
J2518
K2818
L3018
M2527
%2522
£3027
SHIFT_L915
>719
W320
X720
C820
V1714
B2114
N2920
?2520
.2820
/3020
+2927
SHIFT_R926
FN2122
CTRL111
OPTION_L2418
COMMAND_L2320
SPACE2416
COMMAND_R2319
OPTION_R2422
LEFT_ARROW2519
UP_ARROW2827
DOWN_ARROW2822
RIGHT_ARROW3019

I'm open to collaborating with you, especially in documenting the internals of this keyboard. One initial idea that comes to mind is confirming whether the matrix is indeed the same across all keyboards, regardless of the region.

Until then, best of luck with your project, and I hope it succeeds! :)
« Last Edit: Sat, 02 September 2023, 05:29:39 by Limentic »

Offline Limentic

  • Thread Starter
  • Posts: 12
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #10 on: Sat, 30 September 2023, 19:15:42 »
Hey folks,

I've been quite occupied this month, but I still managed to squeeze in some time to work on this project :)

Taking a break from the electronics side, especially the Touch ID part where I haven't quite figured out how to reverse engineer the ribbon, I've mostly wrapped up the CAD work, and it was crucial to kick off the CAD anyway.

How am I supposed to design the final circuit board if I don't know the size and shape? And where I need to put the connector to line up with the one on the Apple motherboard? What shape and size should the touch ID ribbon be, etc.
Basically, it was needed to figure out how the components will be laid out in the case.

Given my unconventional keyboard layout, I scoured the internet for hours but couldn't find THE keyboard case I was after. So, I took matters into my own hands, which makes more sense for my project anyway.

I wanted a case that kinda looked like the original Magic Keyboard, and that's exactly what I've done.
I've replicated the lighting port centered on the back, the angle of the front plane where the keys are, and the overall shape and look. Obviously, I redid everything from scratch since my keyboard is a bit larger than the original.

Here are some pictures of the 3D model of the case:




As you can see, I added a battery holder for the Magic Keyboard battery at the bottom.

The battery will be stuck in place by some iPhone battery strips. Those strips are everywhere, dirt cheap, and they do the job. No need to complicate things with extra pieces of plastic or screws.

The lighting plug will be held in place with hot glue and a snug fit. It's the only way I found to keep it in place because the original method involves two little tubes that go through the connector. Those are tapped, and the connector is screwed into those tubes. It's impossible to find a brass insert that small that could be inserted into a 3D printed plastic tube with such thin walls that passes through the lightning plug without destroying the hole for the inserts, so hot glue it is.

However, the Apple motherboard will be held in place by screws and brass inserts :)

Here's what the original mounting contraption for the lighting plug looks like:


My PCB will be mounted on top, with brass inserts and screws as well, essentially closing the keyboard case.

Here's what the finished case looks like with the PCB mounted on top:


Now, let's talk about the Touch ID keycap!

This keycap is going to be printed in two parts.

The first one is the bottom part, which is the structural part of the keycap. Where the keycap stem is, and where the Touch ID sensor and its frame will be mounted and secured.



The little squared hole is for the ribbon.




The second part is the top part, which is actually just a cover for the metallic frame of the touch ID sensor. It will be held in place with some double-sided tape to the frame of the Touch ID sensor. It's actually what Apple does with the original keycap :rolleyes:.




Here's the final result:



This keycap is going to be printed out of resin or nylon because of the thinness of the top part. It's way too small to be printed with FDM. However, the main case is going to be printed out using FDM (ABS or PLA, I don't know yet), because it's much cheaper for larger pieces.

I don't have access to a 3D printer, so I'll be using a 3D printing service. I'll probably use PCBWay, since I will be ordering the PCBs from them anyway.

Here's the final result of the keyboard case with the PCB and the Touch ID key:



And here's the PCB on KiCad:



I still need to route the traces, but I'm waiting for the ribbon to be reverse-engineered before I do that.

That's it for today; I hope you enjoyed this update! Stay tuned for the next one.

Cheers!

Offline Limentic

  • Thread Starter
  • Posts: 12
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #11 on: Thu, 05 October 2023, 16:57:51 »
Hi guys,

Today, a quick update on the project.

I've been able to reverse engineer the ribbon cable of the Touch ID sensor!
I'm now sure that the button behind the sensor is hooked up directly to the Apple Motherboard, not to the sensor itself.

How I've done it considering how small the pins are?
I've used a microscope camera, spring-loaded needle probes, a multimeter, and a LOT of patience.

A huge shout-out to my local university for letting me use their equipment!
I wouldn't have been able to do it without the equipment they have.

The setup:


As you can see, I taped the ribbon cable to a marble to keep it flat.
I then placed the two ends of the ribbon where the connectors are, close to each other, so I could see and probe them using the needles.


- On the left, the connector to the Apple Motherboard, the Molex 505070-1422
(datasheet https://www.molex.com/pdm_docs/sd/5050701422_sd.pdf)

- On the right, the connector to the Touch ID sensor, the Hirose TF22-16S
(datasheet https://www.hirose.com/fr/product/document?clcode=CL0480-0346-0-00&productname=TF22-16S-0.175SHW(800)&series=TF22&documenttype=2DDrawing&lang=fr&documentid=D169701_en)

To put this picture into perspective, the pitch between two pins on the Hirose connector is 0.35mm (0.0138 inches) and the pad itself is 0.2mm (0.0079 inches) wide.

How did I find where the button was connected?

First, I removed the glue covering the little tiny pads on the Touch ID button.


Then, I probed the pads on the Touch ID button and the pads on the Molex connector to check for a connection between them.
And indeed, there was!

The top pad is connected to the ground and the bottom pad is connected to pin 9 of the Molex connector.

MolexHirose
16, 16, LOCKPAD, 1, 3
26, 16, LOCKPAD, 1, 3
32
4NC
54
6NC
75
811
97
1010
118
129
1312
1414, 13, 15

Now that I have everything I need, I can start designing my custom ribbon, route the final PCB and 3D print the firsts prototypes of the case and the keycaps.

Still a lot of work to do, but there is light at the end of the tunnel!

See you next time!

Offline WizMeister

  • Posts: 3
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #12 on: Sat, 04 November 2023, 06:46:02 »
I registered on this forum to pay respect to your determination! I’m a long time Mac user / software engineer and recently switched to a mechanical keyboard. Touch ID is the reason I have the Magic Keyboard still on my desk.

Would be super awesome to see a ready made kit in the market :) 

Offline Limentic

  • Thread Starter
  • Posts: 12
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #13 on: Sat, 04 November 2023, 09:13:01 »
Hey man, I really appreciate the support, and your message means a lot to me!

I've already considered putting together a DIY kit for those interested.

However, keep in mind that the project will be open-sourced once it's ready :)
In theory, you could send all the files to PCBWay (not sponsored, but I wouldn't mind, lol) for the PCBs and 3D files.
It might get a bit pricey, and you will end up with 5 PCBs even if you only need one, but you'd still be able to build a keyboard ;)

I'm not against the idea of creating a kit, but I need to assess the level of interest. If only two people are interested, that won't cut it, xD.

Here's a sneak peek for you, at the current state of the project:

Offline ankit

  • Formerly ankit-sachdeva
  • Posts: 463
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #14 on: Sat, 04 November 2023, 11:58:10 »
insanely cool, can't wait to see the finished result
collection:
More
  Daal, Emp Mini, HHKB x5, Horsey, Prophet, RS60, Seis Cero, Unikorn, Pixy Mini

Offline WizMeister

  • Posts: 3
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #15 on: Sun, 05 November 2023, 03:06:54 »
insanely cool, can't wait to see the finished result

Awesome!!! Please keep posting updates  :cool: :thumb: :cool: :thumb:

Offline Applet

  • Posts: 488
  • Location: Sweden
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #16 on: Mon, 13 November 2023, 05:56:41 »
Fun project! Thanks for sharing the process with us ;D

Offline Limentic

  • Thread Starter
  • Posts: 12
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #17 on: Sun, 26 November 2023, 15:56:44 »
Hi guys,

A quick update for you all, I've been very busy this month and haven't had much time to work on the project, but I've still got some news for you.

As you've seen in the previous post, I've got a 3D printer now, thanks to a friend of mine that has gone into the navy and left me his printer.
He's said:
"I'm not going to have much use of it where I am going, so you can have it for a while xD"

That's great because I can now print everything by myself and don't have to go to the local hackerspace anymore or rely on a 3D printing service to iterate on designs.

The most complicated part of this keycap creation was getting the tolerances right for the touch ID sensor. As you can imagine, no one has the dimensions for it, and my digital calipers are from the dollar store, so they are not very accurate.
Here's a picture of all the attempts I've made to get the tolerances right, and even now it's not 100% perfect; it's 99% there.
I'm happy with it because I'm not sure if Ender 3 is even precise enough to get those tolerances tight enough.


I was trying to replicate the same principle as the original keycap, where the touch ID sensor is mounted to the bottom part of the keycap and a cover is placed on top of it with a little bit of double-sided tape to hold it in place.
It's the same thing that Apple does on the magic keyboard anyway, so I thought it would be a good idea to do the same.

Here are some pictures of the whole process of sanding the keycap, priming it, painting it, and finally putting the touch ID sensor in place.







But as you can see, the small gap is quite noticeable, and after discussing with a friend of mine, he suggested a different approach.

Instead of having only a cover on top of the sensor, why not make the cover the whole keycap but gutted. The sensor would be mounted to a bottom part where the keycap stem is, and the cover would be mounted on top of it.
I had already thought about this, but I didn't think it would be possible because nothing would really hold the cover / keycap body in place, but the more I thought about it, the more I realized that it could work.
Because in reality you will never push on the cover, you will only push on the sensor, so the cover doesn't need much strength, a bit of double-sided tape and a tight fit should be enough to hold it in place.
And of course, it worked!

Here's pictures of the final keycap:


The 3D model of the keycap needs to be redone, but I'm happy with the result for now.
I'm going to start to open source the project soon, I'm just waiting for the case to be done and the PCB to be finalized, and I'll put everything on GitHub.

That's it for today, I'll keep you updated on the progress of the project!

See you next time!
« Last Edit: Sun, 26 November 2023, 16:02:33 by Limentic »

Offline WizMeister

  • Posts: 3
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #18 on: Thu, 07 December 2023, 13:16:11 »
Awesome news!!! This will be my first attempt at a custom made keyboard, once it’s open sourced 😂

Offline Nlight

  • Posts: 57
  • Location: France
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #19 on: Mon, 11 December 2023, 07:59:14 »
I don't know if the printer you're using is a classic fmt of not. But if it is, keep in mind that using it with ABS has a huge advantage : acetone. Indeed acetone can be used instead of any glue, it will fuse ABS together.
That way you could pressure fit your key together and use a little bit of acetone to seal in place. That could cause some problems if you ever need to disassemble it though.

I made a plate in several parts fused together with acetone, it's super strong.

Anyway, great job man, even though you're just a Mac bourgeois (révolution ! A mooooort ! 😋)

Offline Limentic

  • Thread Starter
  • Posts: 12
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #20 on: Sat, 20 January 2024, 06:49:23 »
Hi, guys. Sorry for the lack of progress lately. I've been very busy with my personal life, and I don't know when I will be able to resume work on this project. But don't worry; it's not abandoned or anything :)

I've also 3D printed the first prototype of the case, and I'm pretty pleased with it! Small things need to be fixed, like the fact that I forgot to add a way to turn on and off the keyboard. :facepalm:

Here are some pictures:
(For obvious legal reasons, the Apple logo will not be present on the files I will give to you)









I don't know if the printer you're using is a classic fmt of not. But if it is, keep in mind that using it with ABS has a huge advantage : acetone. Indeed acetone can be used instead of any glue, it will fuse ABS together.
That way you could pressure fit your key together and use a little bit of acetone to seal in place. That could cause some problems if you ever need to disassemble it though.

I made a plate in several parts fused together with acetone, it's super strong.

Anyway, great job man, even though you're just a Mac bourgeois (révolution ! A mooooort ! 😋)

Thanks for the feedback, man ;) I appreciate it.
Yes, I'm using FMT, but I'm printing with PLA and not ABS. I feel ABS is too complicated (and a little bit unsafe with the fumes) for me as a beginner in the 3D printing world. But yeah, it could be a great alternative to avoid the little gap.

Yes, I know I'm a Mac bourgeois and an Apple enthusiast in general, but everyone has their flaws, right :))

Anyway, see you next time guys!
Have a great day!

Offline Chong_Feng

  • Posts: 1
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #21 on: Sun, 21 January 2024, 10:39:05 »
Awesome, you did what I wanted to do and I thought I'd follow you for a few days.

Offline TomahawkLabs

  • Posts: 110
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #22 on: Mon, 22 January 2024, 10:09:29 »
Truly doing what this hobby is about. Diving into the passion side of it. I will continue watching this. Very much a motivator for my own project(s). Keep it up!
Always looking for Alps SKCM/SKCL switches. Feel free to DM.
AMD 5600x | RTX3080 | 2x 1TB NVME + 4x 4TB HDD | B550M Pro-P | 32GB RAM | RM850x | Node 804 | Schiit Modius/Magnius + Audeze LCD-2 | Dell S3422DWG
GMMK 1 Full Size Barebones | Zealio 67g ; Apple M3501 handwired | Alps SKCM Damped Cream
SA: Camping

Offline Numbuh

  • Posts: 2
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #23 on: Thu, 01 February 2024, 07:25:47 »
You’ve inspired me to work on mine too. The matrix on full size is slightly different so when I'm done I'll update it

Offline matthewfcarlson

  • Posts: 1
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #24 on: Tue, 06 February 2024, 16:58:09 »
Howdy Limentic! I registered to be able to comment! I've been working on a mechanical magic keyboard since May 2022 (yeah I know I'm slow). I'm slowly working on a write-up but I should have been releasing incremental updates as you've done! I searched again on a whim (since nothing came up in 2022) and your post came up. The dedication to scan the matrix and hand-label it is nuts! I created a PCB with several mux chips (CD74H) so I can just scan the matrix while I press each key. I used a full-sized one as a few others have done, but I'm using Gateron low-profile switches to try and keep it similar to the trackpad I have at work. I intend to have the numpad detachable and able to clip to either side with magnets and pogo pins but I think I'm still a ways off.

Anyway- long way of saying awesome job and thank you!

Offline saintlouisbagels

  • Posts: 1
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #25 on: Sun, 19 May 2024, 20:50:41 »
I randomly remembered your Post on LTT Forums and decided to make an account here to express my support of this huge undertaking of such an interesting project! I love mechanical keyboards and Apple's Magic Keyboard, so seeing someone trying to marry the two is such a damn cool concept!

Offline Limentic

  • Thread Starter
  • Posts: 12
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #26 on: Mon, 20 May 2024, 02:48:27 »
Howdy Limentic! I registered to be able to comment! I've been working on a mechanical magic keyboard since May 2022 (yeah I know I'm slow). I'm slowly working on a write-up, but I should have been releasing incremental updates as you've done! I searched again on a whim (since nothing came up in 2022), and your post came up. The dedication to scan the matrix and hand-label it is nuts! I created a PCB with several mux chips (CD74H) so I can just scan the matrix while I press each key. I used a full-sized one as a few others have done, but I'm using Gateron low-profile switches to try and keep it similar to the trackpad I have at work. I intend to have the numpad detachable and able to clip to either side with magnets and pogo pins, but I think I'm still a ways off.

Anyway- long way of saying awesome job and thank you!
Thanks Matthew, scanning the matrix using mux chips is also a good approach to the problem, but because I'm kinda broke, cheap, and I don't value my time ;D The hand-labeling process of the matrix seemed like a good idea at the time! (And I am very proud of the beautiful wallpaper I've created in the meantime :))

Good luck with your keyboard; I even think you will be done before me :D
Doing a Masters in EE and working on side projects don't mix very well, lol (who knew, right?)

I randomly remembered your Post on LTT Forums and decided to make an account here to express my support for this huge undertaking of such an interesting project! I love mechanical keyboards and Apple's Magic Keyboard, so seeing someone trying to marry the two is such a damn cool concept!

Thanks, man, for taking the time to make an account just to post on here (thanks Matthew for that as well) just to show support! It's nuts for me to see this niche project getting so much attraction; I am so grateful for that.

I wanted to reply to both of you guys, to first, reply to you, but to show that this project isn't dead, and I really want to finish it, but the only thing I lack is time, really. Sometimes, you wish you were a YouTuber, right?

Offline The One

  • Posts: 5
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #27 on: Tue, 21 May 2024, 10:17:58 »
Can't wait to see more updates!! :thumb:

Offline nbredia

  • Posts: 1
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #28 on: Mon, 27 May 2024, 17:27:44 »
Commenting on this so I can come back to it. The amount of effort you have put in is truly amazing. Do you think it would be possible to use less keys? (40% for example)

Offline Numbuh

  • Posts: 2
Re: [BUILD] Magic Keyboard 2 but mechanical
« Reply #29 on: Tue, 28 May 2024, 01:23:24 »
Commenting on this so I can come back to it. The amount of effort you have put in is truly amazing. Do you think it would be possible to use less keys? (40% for example)
It can be don with ease. You just create matrix for keys you need. All you cans do is map key behavior 1:1 and create custom layout