CBM 64’ed: Attach a Commodore 64 Keyboard to Your Computer

CBM Keyboard connected to a Teensy++ 2.0

CBM Keyboard connected to a Teensy++ 2.0

There are reasons against this. Your friends and colleagues who are not as nearly as nerdy as you are will smile, perhaps a bit shamefacedly. You and your keyboards. Now this: you found this Commodore 64 keyboard somewhere in the bay or at your local flea market and you immediately wanted it to connect to your PC or Mac. No problem, there are enough recipes in the net, and here’s mine. Even if you are not a great tinkerer, this shouldn’t hinder you. All you need is a

You may want to warm up yourself a bit if you haven’t done this before. I’d recommend following this tutorial which explains all install procedures and first bricolages. After recreating these and playing with the Keyboard sample, you’re ready.

There’s a bit of theory before proceeding, and Simon Inn’s article gives great information on the CBM 64’s keyboard layout. Each keyboard has a matrix circuit which makes the cabling of keyboards much easier than just wiring each single key to a chip. Making a keyboard USB-ready although it was constructed decades before USB requires a bit of reverse engineering, and this is well explained in Simon’s post.

After this, we are having a look at Anders Tonfeldt’s video series on his approach; he is using different hardware, but I found his solution rather inspiring. If you put a little time into this research, you’ll be ending with something like this:

C64-Keeb

Layout: CBM 64 Keyboard to Teensy++ 2.0 via USB to PC/Mac

This is the layout: connect the 64’s pins to your Teensy as depicted.

What’s missing now is the software, the program logic that interprets the various keypresses on the CBM 64 keyboard and sends them as keycodes to your computer. Find it here. It’s based on code written for a PET keyboard which I adapted to my needs.

 

Since the Commodore 64 has a very different key layout I’ve translated the special keys:

  • Commodore key: becomes the Command (Mac) or Windows/GUI key (PC)
  • INST DEL: Backspace; becomes Delete when shifted
  • CLR HOME: Home; becomes End when shifted
  • RUN STOP: becomes Alt
  • Arrow up: becomes \, | when shifted
  • Restore: becomes Tab (there is no NMI we would have to take into account anyway)
  • CTRL, both Shift keys, cursor keys remain their original functions

Some keys caused me a bit of pain, though: ‘:’ and ‘;’ will work as expected, but shifting won’t give you braces ‘[‘ and ‘]’. Also, ‘£’ (which I tried to produce ‘{‘ and ‘}’) was a bit unruly. But let’s not overthink this. Your Commodore keyboard will be recognized as external keyboard and you’re ready to go. This is no high-end keyboard, its mechanics is rather wobbly, but it’s an interesting topic nonetheless which adds the keyboard of one of the most popular computers to your nerd machinery. Enjoy!

About Manfred Berndtgen

Manfred Berndtgen, maintainer of this site, is a part-time researcher with enough spare time for doing useless things and sharing them with the rest of the world. His main photographic subjects are made of plants or stones, and since he's learning Haskell everything seems functional to him.