KeyV2: A Parametric Mechanical Keycap Library
Go to file
2018-09-05 14:34:52 -04:00
.github/ISSUE_TEMPLATE Update issue templates 2018-07-27 12:12:37 -04:00
assets add welcome banner 2018-07-05 20:00:51 -04:00
src make centered_tines support stabs 2018-09-05 14:34:52 -04:00
.gitignore keep models directory around though 2018-07-05 20:07:59 -04:00
.node-version add gulp files and an explanation of build process options 2018-06-03 16:14:17 -04:00
customizer_base.scad various small fixes while preparing for release 2018-07-26 01:48:20 -04:00
customizer.scad doy 2018-07-26 02:24:29 -04:00
expand.rb remove models directory and switch to generating them via script 2018-07-04 21:12:07 -04:00
gulpfile.js few quick updates to the gulp file 2018-06-03 16:19:33 -04:00
key_mold.scad small changes to mold 2018-06-03 13:29:51 -04:00
keys.scad various small fixes while preparing for release 2018-07-26 01:48:20 -04:00
keysets.scad add newly generated base models 2018-02-12 21:36:36 -05:00
model_base.scad remove models directory and switch to generating them via script 2018-07-04 21:12:07 -04:00
models.rb various small fixes while preparing for release 2018-07-26 01:48:20 -04:00
openscad.rb remove models directory and switch to generating them via script 2018-07-04 21:12:07 -04:00
package-lock.json add gulp files and an explanation of build process options 2018-06-03 16:14:17 -04:00
package.json add gulp files and an explanation of build process options 2018-06-03 16:14:17 -04:00
README.md README fix for keys with labels. 2018-07-27 19:23:42 -06:00

Parametric Mechanical Keycap Library

Welcome!

This library is a keycap and keyset construction library for mechanical keyboards, written in openSCAD.

Relevant links:

How to run

Thingiverse Customizer

The easiest (though not the best) way to run this program is to boot it up in Thingiverse's Customizer. Explanations of each option are provided, as well as some default variables. Twiddle the variables to see how the keycap changes!

OpenSCAD Customizer

If you find that the Thingiverse Customizer is timing out, but you're not technically inclined enough to start programming in OpenSCAD, you can look into getting OpenSCAD's customizer working.

OpenSCAD Proper

First, you'll need OpenSCAD: http://www.openscad.org/downloads.html. I highly recommend installing the development snapshot, as they are much further along than the current stable release (as of writing, 2015.03-3).

After you have openSCAD installed, you need to download the code and run it. running git clone https://github.com/rsheldiii/openSCAD-projects.git if you have git, or downloading this zip and extracting the code should do it. Then all you need to do is open keys.scad with openSCAD and you are set! It is possible to edit this project with an external editor by checking off Design => Automatic Reload and Preview in OpenSCAD.

All examples below assume you are running the library on your computer with OpenSCAD.

Let's Go! I wanna make a custom keycap!

At the highest level this library supports Cherry and Alps switches, and has pre-defined key profiles for SA, DSA, DCS, G20 and (some form of) OEM keycaps. keys.scad is meant as an entry point for everything but the most technical use. Pre-programmed key profiles can be found at the key_profiles directory.

Every key starts with defaults that are overridden by each function call. The simplest cherry key you can make would be:

cherry() key();

a bog-standard cherry key

which is a bog-standard DCS row 5 keycap. To change key profile or make varying width keys, you can use the row and unit length functions, like so:

sa_row(2) 2u() cherry() key();

a 2 unit SA row 2 cherry key

What if I want to customize my keycaps?

There is a bevy of supporting functions to customize your keycaps. You can add a brim to more easily print the stem, switch up the stem support type, make 2x2 keycaps for a POS system, add legends, rotate stems, and more. These functions can be found in key_profiles/, key_sizes.scad, key_transformations.scad, and key_types.scad currently, and can be referenced directly in keys.scad. For a full list of helper functions with explanations, Check out the wiki!

Example customizations

If you wanted to generate some 2u stabilized keycaps for an Ergodox for instance, you could do something like this:

legends = ["Enter", "Escape", "Tab", "Shift"];
for(y=[0:3]) {
  translate_u(0,y) 2u() dsa_row() stabilized() cherry() key(inset=true) { keytext(legends[y], [0,0], 6); }
}

a set of 2 unit keys with legends

The key() function also supports children, and will place them in the center of the top of the keycap, if you want to quickly design your own artisan keycaps:

cherry() key() {
  translate([-6.25,2.3,-0]) scale(0.074) import("Assieme1.stl");
};

an artisan key with no-face on it

(no face courtesy of this thing)

Artisan support also supports subtracting children by doing key(inset=true) { ... }, which is super helpful if you want to make keycaps with legends that are not text. The children will be placed just above the middle of the dish as per usual; you will need to translate them downwards (ex translate([0,0,-1])) to get them to 'dig in' to the top of the key.

What if I want to get really technical?

At the base level this library should function well as a key profile design library. by loading up src/key.scad (notice no s) you can tweak variables in src/settings.scad to prototype your own profiles. There are currently 44 different settings to tweak in src/settings.scad including width height and depth of the keycap, dish tilt, top skew, fonts, wall thickness, etc. If you want to see the full list of settings, feel free to browse the file itself: settings.scad it has lots of comments to help you get started.

What if I want to get even more technical than that?

Now we're talkin!

This library should be abstract enough to handle new dish types, keystems, and key shapes, in case you want to design your own Typewriter-style keycaps, support buckling spring keyboards or design some kind of triangular dished profile. src/shapes.scad src/stems.scad and src/dishes.scad all have a 'selector' module that should allow you to implement your own creations alongside what already exists in their constituent folders.

If you're interested in this, it may help to read the Technical Design of a keycap wiki page.

Here's an example of tweaking the settings and code to make a 'stoinstancep sign' key profile:

In key_shape() in shapes.scad:

 else if ($key_shape_type == "stop_sign") {
   stop_sign_shape(size, delta, progress);
 }

in src/shapes/stop_sign.scad:

module stop_sign_shape(size, delta, progress){
  rotate([0,0,22.5]) circle(d=size[0] - delta[0], $fn=8);
}

In keys.scad:

union() {
  // make the font smaller
  $font_size = 3;
  // top of keycap is the same size as the bottom
  $width_difference = 0;
  $height_difference = 0;
  $key_shape_type="stop_sign";
  $dish_type = "cylindrical";
  // some keycap tops are slid backwards a little, and we don't want that
  $top_skew = 0;

  legends = ["Stop..", "Hammer", "time!"];

  for(x=[0:len(legends)-1]) {
    translate_u(x) cherry() key(legends[x]);
  }
}

three stop-sign shaped keys with legends

Printing Help

Prints from this library are still challenging, despite all efforts to the contrary. Resin printers can create great looking keycaps; FDM printers can create usable keys that look alright, but may require tweaking to get prints acceptable. There are a few quick things that you can do:

  1. If your stem isn't fitting in the switch, try upping the slop factor, accessed by giving your keystem function a numeric value (eg cherry(0.5) key()). This will lengthen the cross and decrease the overall size of the keystem. The default value is 0.3, and represents millimeters. Note that even if you have a resin printer, you should probably keep the default value; keys printed with 0 slop will barely fit on the stem.

  2. If your keystem breaks off the bed mid-print, you can enable a brim by adding the brimmed() modifier. This will give a solid base for the keystem to anchor into.

  3. If you are unsatisfied with the quality of the top surface, you can try printing the keycap on a different surface than the bottom, though it may impact the quality of the stem.

  4. If your newly-designed key shape is crashing into the switch, you can enable a clearance check for cherry switches by adding $clearance_check = true; to your keycap declaration. This will subtract a cherry switch shape from your keycap, highlighting any parts in red which intersect with the switch.

That's it, if you have any questions feel free to open an issue or leave a comment on thingiverse!

TODO:

  • replace linear_extrude_shape_hull with skin_extrude_shape_hull or something, to enable concave extrusions
  • replace current ISO enter shape with one that works for skin()
  • generate dishes via math?