Close
0%
0%

Keybon – Adaptive Macro Keyboard

Customizable OLED keyboard that adapts to the apps you use

Similar projects worth following
Keybon is a macro keyboard with configurable layouts and functions. Integrated into each of its nine tactile buttons is a 0.66” OLED screen. Depending on which app is active on the connected computer, Keybon switches to the suitable key layout thanks to its companion software.

Some of the key features are:
• Standalone Mode as a USB HID device
• Companion-Software for customization and app-switching
• Tactile switches
• 0.66” 64x48 px OLED displays
• Fully 3D-printed case and key mechanism

Layout files, code and STLs on Github: https://github.com/CoretechR/Keybon

How it works:

  • In Standalone mode, Keybon acts as a simple HID keyboard and shows its preconfigured buttons functions.
  • The companion software for windows allows you to create your own keyboard layouts and assign them to any application on your PC. The companion software monitors the applications in focus and changes the layouts accordingly. In this mode Keybon communicates over a virtual COM port. Layouts are sent to the device on demand which in turn sends key events back to the computer.

  • 1 × 0.66in OLED (UG-6448KLBEG03) Bought from LCSC, but must 0.66" OLEDs should be compatible
  • 1 × STM32F103C8T6 Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers

  • Companion App

    Max.K12/09/2020 at 20:32 0 comments

    Without the appropriate desktop software, Keybon is just a programmable keyboard. The goal was to add the ability to configure the device from windows and change keyboard layouts on the go. I decided to create a windows forms application in C#. 

    The application works like this: You connect to the keyboard via a COM port. Then you configure the icons that are displayed on the OLED screens and the macro functions for each button. This can be done via drag&drop for the images. The button commands need to be entered in a way the “sendkeys” method can interpret them. For example, +{h}{e}{l}{l}{o} prints “Hello” when pressing the corresponding button. You can create up to 8 layouts, but there is really no hardware limitation to this. As the layouts are only saved on the computer, the STM32’s memory is not the limiting factor. When a layout is activated, the application sends a command to the keyboard that disables its HID function. After that, the nine images are transferred via the COM port as a stream of bytes. This takes only a few milliseconds, so the change on the actual OLEDs is instant. To each layout a set of windows processes can be added. The software constantly checks what application is running in the foreground. If for example Google Chrome is opened, the software instantly switches to the matching layout.
    As this was is my first C# project, making the app took some time and effort. By splitting the functionality into small parts, each problem became solvable. Detecting foreground apps has fortunately been well documented. Writing images to the keyboard was just a matter of efficiently splitting bitmaps into bytes. One of the most complicated part was saving and loading settings. I decided to use the feature built into Visual Studio, that saves a single .xml file to “users/appdata/…”. This way the .exe works without an install or a visible settings folder. As .xml files are text based the bitmap information needs to be serialized first and reassembled into an image later. After all I am quite happy with the companion software. There are of course plenty of usability features that could be added, but the basic functionality is sufficient to use the keyboard productively.

  • Electronics

    Max.K12/09/2020 at 20:31 0 comments

    For connecting the keyboard to a computer, USB was the obvious choice. Not having to care about low-energy was a welcome change from my previous, mostly battery-powered projects. The first microcontroller that came to my mind was the Atmega32U4 as it has built-in USB support and does not need a separate USB to serial converter. But one problem is its small SRAM with only 2kB. When using displays their pixel values are usually saved in RAM, so that the image can be easily manipulated. For a first iteration of the keyboard, I was planning to use nine OLEDs with 64x48 pixels each. This adds up to 3456 bytes of memory. It would be possible to use the Atmega with some software trickery, like keeping only one screen in memory and cycling through them. But I did not want to risk running into performance problems later. Instead, I decided to use the ST STM32F1 as it is cheap, has USB support and upwards of 20kB RAM. It also is officially Arduino-compatible, known for being used in the Blue-Pill boards. 

    With all parts select I created a compact PCB that would hold nine OLEDs. The board contains mounting point for the 3D-printed button mechanism. On the “chin” of the device, where the levers of the last row of screen sit, there is just enough room for a USB-C connector and the STM32F1.Ultimately the wiring of this PCB is very simple. The STM32 is supplied by the USB connection and a 3.3V regulator. The regulator (AP2112K) also powers the nine LEDs, which contain internal dc-dc converters to create their working voltage of around 9V. USB-C is used for the connector, but it is wired as regular USB2.0. As the OLEDs can only assume one of two I²C addresses I had to use SPI. That means they share all data lines but they each have their own chip select.

    Assembling the board can be tricky as the OLEDs have to be soldered in first before the 3D-printed mounts are put in place. There is only enough room to get them in place in a certain order without damaging the display connectors. I did not want to leave the PCB and mechanisms exposed so designed and printed a simple case. The PCB snaps into it and the buttons get covered with a face plate. I originally planned to put transparent acrylic on the OLED panels, but it looks much nicer without them. As the screens are made from glass, scratches should not be a big issue.

    The STM32 can be programmed via USB after initially flashing the USB bootloader (stm32duino bootloader). Currently there are two different Arduino implementations for the STM32 boards. An official one by ST and the Arduino_STM32 port by Roger Melbourne. The latter contains more features, including some that are needed for this project. To make the keyboard work as a HID (human interface device) I used the STM32F1 USB composite library. With this library the STM32 cannot just mimic a HID device, but a serial port simultaneously. This enables the keyboard to be controlled over a COM port while still being an independent HID keyboard. The firmware I created is very simple as the Adafruit GFX library includes most the code needed to drive the displays. What turned out to be much more complicated was the desktop app that would be used to control the keyboard.

  • Hardware

    Max.K12/09/2020 at 20:26 4 comments

    The first task was to figure out how to build a button with an integrated display. There actually are off-the-shelf solutions: NKK switches manufacture tactile switches with color displays. But at a crazy 50€ or more per key these are out of the question. Early on I decided to use small OLED displays as they are widely available and inexpensive at under 3€. 

    I found that 0.66in OLEDs are just the right size to allow for a compact keyboard. And their 64x48 pixels provide enough resolution to display useful icons. The displays consist of a glass panel with a flex connector that can be soldered directly to the PCB. When bending the connector under the display glass, a gap of a few mm is formed, just enough to fit a thin tactile switch in it. What’s left is a mechanism that supports the display so that when the OLED is pushed, the tactile switch is pressed.
    Figuring out the key mechanism turned out to be challenging. The display has a big surface area compared to the tiny tactile switch. When pressing the button, the force needs to be evenly distributed. If not, pressing on the edge of the OLED will just rotate it around the button. I learned this when I 3D-printed my first OLED mount. It simply holds the display in place but does not limit its rotation:

    Laptop keyboards solve this by using a scissor mechanism that restricts the key to a linear motion. However, I could not think of an easy way to 3D-print this mechanism without making it unnecessarily big. The solution for me was to add a cantilever to the display mount. This lets the display rotate around the point where the levers are connected to the PCB and the motion is sufficiently linear for the tactile switch to be pressed.

    I continued to create a single button keyboard as a proof of concept. After a few iterations the mechanism was working. Whatever point on the screen was pushed, the button was actuated with a satisfying tactile click. The cantilever mechanism is very compact as it does not add to the height of the OLED itself. It also can be stacked to allow for a tight placement of multiple buttons in a keyboard. For this, the lever of one key overlaps with the screen of the next. 

    With the basics of the macro keyboard working, I went on to select the remaining electronic components.

  • Introduction

    Max.K12/09/2020 at 20:23 0 comments

    Whether you work with CAD design software or edit videos, keyboard shortcuts can really speed up your workflow. Dedicated macro keyboards take this even further by moving the most frequently used commands to individual buttons. While these keyboards are widely available both as commercial products and as DIY projects, they usually are restricted to a predefined set of functions like media controls. There are some exceptions: The Elgato Stream Deck is a keyboard with a cleverly integrated LCD touch display behind transparent buttons. Each button can be configured to have different functions and icons depending on the application you are currently using. Considering the high cost of these devices I set myself the goal of creating a cheaper DIY alternative that is fully configurable. 

View all 4 project logs

Enjoy this project?

Share

Discussions

State wrote 2 days ago point

Hey! Great project!

Friend, I can't figure out where the files for creating the board are located. I want to order in China at the factory.

  Are you sure? yes | no

cegan09 wrote 03/31/2021 at 19:06 point

I have a potentially dumb question. I'm working on a similar project and wanted to check out your companion app. Am I correct that there is no ready to run file in the github? I am very much not a software person. I can physically build the keybon, but I'm a bit slow on software. Any way you can nudge me in the direction of getting the app running?

  Are you sure? yes | no

Max.K wrote 04/01/2021 at 21:43 point

Hi, no problem. The compiled .exe can be found in the releases section on github:
https://github.com/CoretechR/Keybon/releases
It's easy to miss, I might add a hint to the description.

  Are you sure? yes | no

cegan09 wrote 04/02/2021 at 01:13 point

Well I feel dumb now...  Thank you for pointing me there.
I have an initial hardware prototype that sticks an 0.42" 72x40 OLED into a keycap for Kailh mechanical switches. If I can prove the whole thing out I'll share because it could pair with what you've designed really well. 

  Are you sure? yes | no

Romain wrote 03/24/2021 at 14:33 point

Just an update on Keybon12. I've made the release of v1.0 of the 12 keys version at https://github.com/gromain/Keybon12 .
I've successfully build one too! Code needs a bit more polishing, and I would like to implement a hybrid version of the control system (one where some keys sent directly a command and others are managed by the application). I also want to write a control application for Linux. The serial protocol is quite simple, so this part should not be a problem!

  Are you sure? yes | no

Romain wrote 03/24/2021 at 14:35 point

Also, I have 3 PCBs left, made by JLPCB. I can sell them at cost if anyone wants to try the 12keys version. I'll also have enough components to build one more, so if anyone wants a complete electronics kit (PCB + components including OLED), feel free to chime in!

  Are you sure? yes | no

falias4 wrote 03/23/2021 at 18:06 point

Awesome project! The combination of displays with an companion app is exactly the macro keyboard I was always looking for.

Did you ever think of using some kind of capacitive touch instead of the mechanical switches?
Maybe a transparent touch panel above all displays or single touch sensors beneath every display?

  Are you sure? yes | no

Mihail CHERCIU wrote 03/18/2021 at 11:58 point

I come with new info.
It's true that the chip that I bought is clone form the original ST chip, but the USB finally it's working.

The probable is that the Skillscreen text of C12 and R14 are inverted on the PCB. So the text C12 should be R14 and R14 should be C12. After re-solder the components at correct place everything working as expected.

  Are you sure? yes | no

Max.K wrote 03/18/2021 at 16:04 point

Thank you for confirming that your device is working. A few weeks ago someone ran into the same problem with the silkscreen, so I updated the PCB. You probably ordered your PCBs just before that.

  Are you sure? yes | no

Mihail CHERCIU wrote 03/18/2021 at 18:42 point

I made 2 other Keybon and everything work as expected.

Thank you the this project, very useful !

  Are you sure? yes | no

Mihail CHERCIU wrote 03/15/2021 at 11:31 point

Ready to assembling few Keybon and test :)

Just received the PCB and components

  Are you sure? yes | no

Mihail CHERCIU wrote 03/17/2021 at 23:02 point

Just for info, maybe someone will have the same problem like me with USB communication.

Because there is not more STM32F103C8T6 in stock to buy from distributor like Mouser, Farnell, etc., I bought from ebay few boards bleupill with STM32F103C8T6.

I de-solder the STM32F103C8T6 from Bluepill and re-solder it on keybon.

The problem is that the chips are fakes and the USB doesn't work. You can program the bootloader and the keybon firmware but PC will fail to detect the USB. I try with Windows 10, Windows 7, Ubuntu and Fedora.

The text on chip is slightly different from the original ST chip.

However, I program the keybon firmware using serial port at 0x08002000, which allow me to test and verify if OLED dislpay are working correctly.

  Are you sure? yes | no

Romain wrote 03/11/2021 at 16:23 point

Just for everyone information, I've made a 12 keys version of this. The files are available here: https://github.com/gromain/Keybon12 .
I'll have enough components to build 3 of them by the end of the month, so if anyone wants one, chime in.

  Are you sure? yes | no

Max.K wrote 03/15/2021 at 20:31 point

That's awesome! 12 is probably the ideal number of screens. Any more than that and you'd need multiplexers and software optimization.

  Are you sure? yes | no

Romain wrote 03/15/2021 at 23:39 point

Exactly why I stopped at that number! :-D I also feel that 16 is nice in terms of keys available, more than that and you spend more time looking for what you want to push!

Ah damn, now I want to work on a 16 screen version! Oh well, if I have time, I'll try something!

  Are you sure? yes | no

Daniel Thompson wrote 02/27/2021 at 17:20 point

Hi great project I'm just having some difficulties flashing the software to the chip. Are you able to explain what you mean in earlier comment about pulling to reset? I have tried shorting route one by using tweezers to bridge the pads. My computer to take to the device has an unknown USB device but then nothing further happened when trying to flash the software. Any help appreciated thanks.

  Are you sure? yes | no

Max.K wrote 02/28/2021 at 15:29 point

To get into bootloader mode you need to have the BOOT1 jumper closed while resetting the chip. To reset it, connect the RST line to GND, then disconnect it.
I recently added some instruction to the Github page, maybe these are helpful:
https://github.com/CoretechR/Keybon

  Are you sure? yes | no

Daniel Thompson wrote 02/28/2021 at 16:00 point

Hi, thanks for the swift reply. That is really helpful I will follow those instructions. One final question (I hope) what/where is the RST line and how best to connect it to ground?

  Are you sure? yes | no

Max.K wrote 02/28/2021 at 18:38 point

There is a reset button on the top of the pcb that you can use. You can alternatively just power on the board while Boot1 is shorted. Whenever the STM32 boots up it checks the states of the boot 1&0 pins.

  Are you sure? yes | no

rand wrote 12/31/2020 at 02:20 point

And cannot be found anymore. artlebedev has gone on to more marketable "knick-knacks."

  Are you sure? yes | no

morganyunker wrote 12/24/2020 at 12:11 point

Great idea. I did something similar but the windows app was a python script.

Looking at the C# code, I see that there is a
SendKeys.SendWait(Layouts[currentLayout].keyCommand[keyReceived - 49]);
in the portDataReceived function.

What is that used for?

Doesn't the board send key commands to the host as a standard USB HID?

Thanks!!

  Are you sure? yes | no

Max.K wrote 12/24/2020 at 12:53 point

When using the companion app the keyboard sends keystrokes as serial commands. These are always the same no matter which layout is selected. The app then triggers key presses based on the layout. It's just easier that way, as the key information doesn't have to be sent from the app to the keyboard and back via HID commands.

  Are you sure? yes | no

Mihail CHERCIU wrote 12/24/2020 at 11:38 point

Very nice, I will try to build one but this can be a good product. Any plans for that ?

  Are you sure? yes | no

Max.K wrote 12/24/2020 at 22:57 point

Thanks! Turning this into a commercial product requires a lot of work and I currently don't have the time or resources to do this. All the files and parts are available, you only need a soldering iron and 3D printer to build on for yourself.

  Are you sure? yes | no

Mihail CHERCIU wrote 12/25/2020 at 10:42 point

I would say that the the hard work you already made it. But it's true need same extra work to make it as a final product. However Bravo for this project, and do not hesitate to contact me if you decide to go to market, I can help you with the first series regarding PCB and product assembly through my assembling lab www.nextuslab.com

  Are you sure? yes | no

Andrej Rolih wrote 12/23/2020 at 22:13 point

Awesome project. I may actually build it at some point if I have too much time on my hands and if LCSC gets the displays back in stock. Although I guess these ones from Aliexpress should probably work: https://www.aliexpress.com/item/4001226905325.html

One question though... have you considered using a mechanical keyboard switches instead? Something like Kailh Low Profile switches should be suitable enough for this. They would of course add some thickness, but you get the benefit of clickiness.

  Are you sure? yes | no

Max.K wrote 12/23/2020 at 22:24 point

Thanks! The main problem with mechanical switches is the travel depth. The tactile switches I used here only move a fraction of a millimeter, so the display cable is only slightly bent. Mechanical Switches would need an entirely different mount for the screens.

  Are you sure? yes | no

Andrej Rolih wrote 12/23/2020 at 22:37 point

True that. Didn't even think of that.


Time to order some parts then I guess. Lol.

  Are you sure? yes | no

Ruben wrote 12/23/2020 at 17:52 point

Cool project! We had considered going with a similar design for our [Adaptive Universal Remote](https://ttec.dev/adaptive-remote), but with ePaper for ultimate power savings as our device would run off of batteries. For a number of reasons, we ended up not going that route.

  Are you sure? yes | no

morgan wrote 12/23/2020 at 17:22 point

It looks like the screen are being pressed directly, do you think there will be issues with strain? Possibly leading to cracking? I've got a bag of 0.44" OLED screen that were also destined for a keyboard, but with a much (much) more complex mounting system specifically to limit contact on the screen.

  Are you sure? yes | no

Max.K wrote 12/23/2020 at 17:56 point

Well, I would not recommend doing this for a commercial product, it would at least need some kind of screen protector. But the OLEDs are quite robust. I doubt you could crack the screen unintentionally with your finger when it is mounted like this. The flat flex cables are more fragile, they are probably the first thing to break over time. 

  Are you sure? yes | no

der_picknicker wrote 12/21/2020 at 10:51 point

I just ordered the parts and PCBs. I'm so exited :)
One question: How did you flash the inital Bootloader? Why did you not expose some header for that purpose?
Super Projekt. Vielen Dank, dass du es teilst :)

  Are you sure? yes | no

der_picknicker wrote 12/21/2020 at 10:52 point

Tere was an issue in the BOM: The 4.7µF capcitors were linked to parts with 0805 footprint, but the footprint used on PCB is 0603.

  Are you sure? yes | no

der_picknicker wrote 12/21/2020 at 11:16 point

Oh, i'm wrong. In the eagle file they are 0805. But in the BOM they are listed as 0603. But the 0603 should also fit. Not the first time i have to fiddle with wrong sized SMD parts ;)

  Are you sure? yes | no

Max.K wrote 12/21/2020 at 12:17 point

Freut mich!

First, power the device up via USB and pull RESET to GND while the BOOT1 jumper is shorted. This will put the STM32 in programming mode. If you are careful you can do this with tweezers instead of soldering. After that you can connect a USB-Serial adapter to the TX, RX and GND pins that are exposed on the back of the PCB. Flash the "generic_boot20_pc13.bin" via the STMFlashLoader software. Links to the files are in the "electronics" project log. If something doesn't work you can ask me or look into one of the tutorials for the "blue pill" board, the process is identical.

  Are you sure? yes | no

nathan wrote 12/18/2020 at 17:31 point

Great project! I'd really like to create one of these for my self.  I'm Just curious What process you used to Solder all the components to the board. Did use a Reflow Oven  and paste or what to solder the Oled's cable etc...  Soldering everything by hand including the The Micro controller would be seemly extremely difficult.  Thx

  Are you sure? yes | no

Max.K wrote 12/18/2020 at 21:23 point

I usually solder the boards with only a regular soldering iron. In a reflow oven the displays would probably need some kind of specialized mount, hand soldering is much easier. 

  Are you sure? yes | no

Romain wrote 12/18/2020 at 14:30 point

Hi! This is super nice project, and I'd like to reproduce it since a macro keyboard could be really super useful for me!
Do you happen to have BOM list around, with the references you used? The schematic is not detailed enough for a proper order based on your design!

Thanks!

  Are you sure? yes | no

Max.K wrote 12/18/2020 at 21:51 point

Thank you! I've just added a BOM with links to LCSC to the GitHub page:

https://github.com/CoretechR/Keybon/blob/main/Eagle%20Files/Keybon%20REV%201.1%20BOM.csv

  Are you sure? yes | no

Romain wrote 12/18/2020 at 22:06 point

Awesome! Thanks a lot!

  Are you sure? yes | no

HannesBro wrote 12/23/2020 at 18:23 point

if I wanted to do this project, too, could you give me a hint where to buy the Parts from the BOM file ? I mean where did you buy the board? I have never worked with such stuff like self designed boards and dont even know how much that costs.

  Are you sure? yes | no

Max.K wrote 12/25/2020 at 09:56 point

@HannesBro Sure, I ordered most of the components from LCSC. They don't have the OLEDs in stock right now but most 0.66 OLEDs should be compatible. Good suppliers for PCBs are OSHPark in the US and Aisler in Germany. They both accept .brd files directly and will show you a preview and the calculated cost of the board before ordering. As the PCB ist quite large it's about 30~40€ for 3 of them.

  Are you sure? yes | no

rand wrote 12/31/2020 at 02:27 point

Max,

I can't seem to get any of those links to work.

Sorry

  Are you sure? yes | no

ekaggrat singh kalsi wrote 12/17/2020 at 22:26 point

really cool project .i saw a macro keyboard the other day and was wondering y the keys need to be hand written and lo and behold i see your amazing oled keys

  Are you sure? yes | no

Kosma wrote 12/17/2020 at 20:39 point

why not normal mechanical button?

i undestand rotor/potenciometer for volume control (i hate button to increase sound) but for keys without keys?

why not big screen with touch screen? small screen with normal keys will be great

  Are you sure? yes | no

Adam wrote 12/20/2020 at 12:05 point

I'm not much of a code monkey, but this project seems to lay the ground work for a separate single screen - it's already got mech switches, so combine the 9 screens into one, and make a case where the screen is separate from the buttons. From a home game design perspective, this doesn't push any boundaries, and practically it will take up quite a bit more desk space.

If you want a touchscreen macro pad, there are numerous Android apps that will serve this function with a low end/repurposed tablet or smartphone, also, there are no design hurdles to be overcome with this approach. 

I, for one, hate touchscreens or capacitive input for simple buttons. There's no way to navigate them without taking your eyes off of your work. You can't rest your finger on one that you will be using repetitively, and sometimes they register a tap while you are trying to hover over them. If you are trying to hover, your finger can wander. There's no tactile/audible response when you've clicked it. The list goes on... There's good reason why game controllers are still button based and not just touchscreens with ergonomic handles, and our desktop keyboards aren't slabs of glass we feverishly tap away at.

  Are you sure? yes | no

Xasin wrote 12/17/2020 at 14:12 point

Wow - this is a stunning project and quite a creative use of the OLED screens like this. I also like their mounting :)
One thing that concerns me a bit is that I never think of these screens as very sturdy, but at the same time, I doubt they will see much abuse here, so it should be fine :)

Maybe I'll do something similar for some of my upcoming DIY Smart Home things, the way everything looks flush and neat is wonderful.

  Are you sure? yes | no

Max.K wrote 12/17/2020 at 16:35 point

Thanks! I was concerned about the OLEDs at first, but they are really sturdy. The mount would snap long before the glass breaks.

  Are you sure? yes | no

Xasin wrote 12/17/2020 at 16:43 point

Ahhh that is good to know, I was going to use one of those smaller OLED screens in an upcoming wearable project.

I made some bad experiences with a WaveShare 128x128 OLED Module where the corners of the OLED screen weren't supported at all, and all the control traces ran through it, so it wasn't too hard to accidentally snap. I guess a good mount design alleviates that.

What about the effects of the pressure on the screen's internal structure? Keep us posted if you see any wear or changes! 

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates