A DIY Keyboard

Here is a real DIY Keyboard - No microprocessors here!

Similar projects worth following
As part of a "Retro" computer project based on a R6502 I needed a keyboard.
Here is a keyboard in keeping with a DIY and Retro.

Not for the Faint of Heart

A keyboard may sound like an easy project but if you search the Internet you will not find many keyboard. I wonder why?

Not all keyboards the Same

A standard QUERTY:


Something more interesting (Apple's first keyboard):


And the Teletype ASR-33:


My Keyboard Layout

Okay so after much work here is my keyboard layout:

Keyboard Trade-Offs

If you look carefully and you will see that some keys have moved (just physical layout) but some keys are mapping differently especially for shifted symbols.

This is because the ASCII code order is less than ideal and moving the codes around is difficult without a microcomputer.

The ASCII Code

So here is the ASCII code:

Ascii Table




The schematic for the keyboard and decoder.

JPEG Image - 649.40 kB - 08/17/2016 at 03:11



The LogicFriday model.

lfcn - 82.98 kB - 08/17/2016 at 03:11



The Tina schematic for the keyboard and decoder.

tsc - 76.23 kB - 08/17/2016 at 03:11



A truth table for LogicFriday.

plain - 3.77 kB - 08/17/2016 at 03:11



A C program to create the truth table for LogicFriday.

C Source File - 1.33 kB - 08/17/2016 at 03:11


  • R6502B

    agp.cooper08/25/2016 at 07:56 0 comments


    I had a PCB for one of these old time microprocessors manufactured.

    They have arrived, three weeks from China - not bad).

    But I am caught out in that I have done nothing on the software side, have no keyboard or display!


    Originally I was going to use BASIC and my keyboard and some sort of video display. But porting this (my IO and memory map are non-standard) will take time. On the 6502 site ( are some simple monitors. VTL02 (VTL-2 for the 6502) by Mike Barry looks like a good starter. Particularly as the header contains the keyboard IO equates etc that I will need.

    I don't have all the components (74LS132 are a bit hard to find) so I did a mail-order. That will buy me two weeks.

    I will have to patch something up for keyboard and a display to get going as well.


  • Indecision

    agp.cooper08/23/2016 at 03:22 0 comments


    I am in two minds whether to go as a single board of to split the board into two?

    Here is the a schematic with the keyboard separated from the PLA:

    The advantages are:

    • One project becomes two smaller projects.
    • A smaller footprint (the boards can be stacked).
    • I can finish the keyboard layout and get the PCB board made.
    • I can drop the PLA if I go for a microprocessor project.

    I think getting the board made (as it takes four weeks) sounds like a good idea.

    Stacking the boards (the PLA underneath) seem pretty straight forward.


  • Updated Physical Design

    agp.cooper08/19/2016 at 06:36 0 comments

    Updated Physical Design

    I bought some cheap(?) 279 mm x 215 mm x 3.5 mm birch plywood some time ago.

    So I have rescaled the keyboard to fit. I only need half the area for the keys:

    This is only the top layer (one of five excluding the PCB). The light blue (cyan) area is reserved for the electronics (which are located underneath) and will be trimmed back once the PCB design has been completed.

    CNC Milling the Boards

    Splintering is a problem when milling cheap wood. To minimise, I have given the first board a light coat of Estapol to seal the surface and will trace the design with an engraver bit first. Then I will use a 0.8 mm end mill to cut out the keys. There are 4x 1 mm diameter holes in the corners to help with dreaded alignment problems. I will likely make these 3 mm in diameter to service as assembly bolt holes.

    I have not worked out what to do with the lettering/symbols.


  • The Hardware

    agp.cooper08/17/2016 at 06:46 0 comments

    The Hardware

    That is the actual keyboard!

    I have made a preliminary design using standard momentary contact switches (the OMRON 6 mm x 6 mm type with a 2.3 mm shaft). It would fit between 3 mm plywood sheets as shown here:

    The pink cap would be 3 mm plywood as well (engraved with the symbol on the top and drilled on the bottom for press fit).

    The preliminary CNC design is presented here:

    A preliminary PCB

    Here is the preliminary PCB:

    The preliminary PCB does not include any the logic components. Looking at this board, all the electronics should me moved to the top of the PCB.

    I am considering the use of these switches (12 mm x 12 mm) as they have a cap built in:

    I should be able to engrave (CNC) the symbols and perhaps fill with black ink the engraving strokes directly on the cap. Alternatively a laser engraver may work here.


  • Remapping the Keyboard

    agp.cooper08/17/2016 at 05:05 0 comments

    Remapping the Keyboard

    Given most of the work is done with the "basic shift logic" how hard could it be?

    The basic shift logic:

    Well much harder than expected, here is the schematic:

    Now many will recognise this as a PLA (Programmable Logic Array).

    Designing a PLA

    The first step is to generate a truth table. The problem is this is not that simple. It gets pretty confusing with 128 cases to consider.

    Really the first step is to write a program to generate the truth table. So here is a simple C code program that creates the truth table:

    #include <stdlib.h>
    #include <stdio.h>
    #include <stdbool.h>
    int main(void) {
      FILE *F1;
      int a,x;
      int a0,a1,a2,a3,a4,a5,a6;
      int x0,x1,x2,x3,x4,x5,x6;
      for (a=0;a<127;a++) {
        // Shift mapping
        if ((a>=32)&&(a<=63)) x=a+64;  // lower case "'" to "Del"
        if ((a>=16)&&(a<=31)) x=a+16;  // Keys "0" to "?"
        if ((a>=0)&&(a<=15)) x=a;      // Ctrl keys as is
        if ((a>=96)&&(a<=127)) x=a-32; // Shift: Upper case "@" to "_"
        if ((a>=80)&&(a<=95)) x=a-48;  // Keys "Space" to "/"
        if ((a>=0)&&(a<=15)) x=a-64;   // Shift: Ctrl keys as is
        // Special key mapping
        if (x==95) x=127; // "_" is now "Del"
        if (x==32) x=95;  // "Shift 0" is now "_"
        if (x==1) x=32;   // key 0 is "Space"
        if (x==2) x=24;   // "Can" or Break/^C
        if (x==3) x=27;   // "Esc"

    Once we have a truth table we determine the Prime Indicants (PIs). I use Logic Friday:

    LogicFriday is a front end for Espresso by Richard Rudell (rudell@ic.Berkeley.EDU).

    Here are the PIs table used to design the PLA:

    So I was not wrong in saying that remapping a few keys is expensive.

    (Now I did try adding the PLA after the "basic shift logic" but the result were just as bad.)


    The keyboard interface pretty basic, a byte with the D7 (Key Pressed) used for polling or an interrupt.


    Note the missing Ctrl and Alt keys. So it will be up the the program to set how extended key codes are entered.


  • Keyboard Remapping

    agp.cooper08/17/2016 at 02:54 0 comments

    Only 64 Keys

    To start I have assumed only 64 keys (maximum) are available for the keyboard. The first key is mapped as code as 0, the last key as code 63. Here is my keyboard switch schematic with the final key mappings (n.b. keys 04, 05 and 06 will not be used):

    Extracting a code from the switches without column and row scanning (which is why a microprocessor is usually used) requires some analog to digital logic (the PNP transistors in the schematic):

    This is the basic keyboard schematic that will map the the key code (not the ASCII code).

    The column codes are A0-2 and the row codes are A3-5.

    As I am using key code "0" I need to know that a key has been pressed, this logic is added to test if a key is pressed:

    Remapping keys and the Shift Key

    We need to add "shift key logic" to remap the key code to ASCII codes, and to map the lower case or shift upper case logic to the keyboard.

    Here is an example of decoding logic ("the basic shift") that could be used to remap keyboard codes to ASCII codes:

    Problems with the Basic Shift

    The basic key shift does 95% of the work needed for a practical keyboard but there are problems:

    • the space (" ") is accessed by shifting "0"
    • the "DEL" is shift "_"
    • the "ESC" and "CAN" (i.e. Break) are not accessible.

    We therefore need to remap some individual key codes around.

    Remapping individual keys is expensive.


View all 6 project logs

Enjoy this project?



esiako wrote 01/25/2022 at 21:34 point

many languages need AltGr in Polish this keyboard is unusefull

  Are you sure? yes | no

agp.cooper wrote 01/26/2022 at 00:46 point

True, but you may have missed the "retro" aspect this project.

Many of my projects are "useless" but are what could have been done in the 70's.
Something I tried to design in my teens but only in retirement do I have the time and knowledge to do so.

The keyboard is a non-microprocessor (i.e. all TTL) design that would only have been useful to a computer hobbyist back in the 70's.

In those days the operating system was CP/M, which used 7 bit serial communications. A TeleType Model 33 would have been a dream peripheral.

My "Weird CPU" is another example of a non-microprocessor computer.

Regards Alan

  Are you sure? yes | no

ryeteur wrote 10/21/2021 at 11:02 point

Seems good, I want to test this keyboard on my mechanical keyboard program, you can see here more detail

  Are you sure? yes | no

Jerry M. Lineberry wrote 10/16/2020 at 05:45 point

If I understand it, you were making a keyboard without a microprocessor/firmware like QMK. I would love to see it in action. How many logic chips are required to do this?

  Are you sure? yes | no

agp.cooper wrote 03/21/2020 at 02:56 point

Yes, nice. The problem I was trying to solve is a super simple 8 bit encoding. Much like the problem you would have faced back in the 80's with regard to developing a keyboard/standard/layout from scratch. Modern keyboard pretty well need a micro-processor to meet the protocol.

When I was designing this keyboard I was planning to use it with home brew computer.


  Are you sure? yes | no

prosto wrote 01/11/2019 at 10:51 point

look this project on right 2 rotor potenciometer

  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