Dalius's blog

Tuesday, December 27, 2022

Morsilka: morse code keyboard

I have made a single button keyboard for Dirty Santa swap which can be used to type anything. This was more fun project and I have spend about 2.5 hours to do it (including hardware and software parts).

Here is video with result:

I assume if I would fall from motorcycle and would be able to use only one finger I would love to have this keyboard.


I did it really simple. I had spare Elite-C microcontroller and spare switch with keycap. As well I have some spare copper wires and some wood. So I have measured what size casing I need and cut out it from wood. Then I have soldered wires to switch and twisted wires to Elite-C without soldering (one to GND and another to D07 or something like that, it almost does not matter) - that works so why bother wild soldering. Than I have flashed this this software (about it below), put everything together and fastened with 2 screws. That’s it. KISS.

Note: Elite-C is overkill for this project and there are microcontrollers with less connections that potentially are even cheaper. You need something with 2 connections and USB basically. I have used what I have.


I have used QMK as I am familiar with it. I have searched QMK’s code base but it seems nobody has done this yet so I have decided to do it myself. Figuring out Morse code’s basics can be done from this Wikipedia article: https://en.wikipedia.org/wiki/Morse_code

When you understand Morse code it actually is very simple and genius. You have binary numbers (where short press or dit or ”.” is 0 and long press or dash or ”_” is 1) of specific length in binary. Then you simply assign letter to each number. E.g. if we have numbers of length 1 then we have two combinations:

  • 0 (dit, or short press) - e
  • 1 (dash, or long press) - t

With length 2 we have 4 combinations:

  • 00 - i
  • 01 - a
  • 10 - n
  • 11 - m

I assume in Morse code they are assigned by frequency of usage. The more common the letter the shorter Morse code is assigned.

Now this is very practical from code point of view as we can write each Morse code as binary number so __ . _ __ becomes _0b1011_ in C language. This allows two things:

  • Writing numbers sorted in source code so you can see which sequences are not used yet.

  • As well you can easily identify sequences that are not used yet.

So this way I have assigned space, backspace and enter to Morse code sequences of length of 4 symbols (as there are 3 such unused).

Now real keyboard has way more buttons and some of them are not defined in Morse’s code, like Win, Ctrl, Alt or Shift. Here I got creative and decided that combinations without break can be used for these buttons. This should be easier for people to remember and type. So I have programmer following letters without breaks to represent these buttons:

  • WI - Win/Start

  • CT - Ctrl

  • SIT - Shift

  • AL - Alt

The last thing was to figure out timings for dits and dash and I have found out that 100ms works best, 75ms is flaky and 50ms does not work. I have not spent time figuring out why it is this way.

Here you can find final source code: https://github.com/daliusd/qmk_firmware/tree/morsilka/keyboards/a_dux/keymaps/morsilka

As well you can download postcard Morsilka cheat sheet if you want to.