// Contains the keycaps

distance_from_key_to_enclosure = 6;
enclosure_hole_depth = 6;
button_height_above_enclosure_surface = 4;
stopper_flange_height = 2;
symbol_height = 1;

module keycap() {
    // Keycap
    cylinder(h = enclosure_hole_depth + stopper_flange_height + button_height_above_enclosure_surface, d = 18, $fn = 128);
    // Stopper flange
    cylinder(h = stopper_flange_height, d = 24);
    // Stem
    stem_height = distance_from_key_to_enclosure - stopper_flange_height;
    translate([0, 0, -stem_height / 2]){
        difference() {
            cube([6.4, 4.4, stem_height], true);
            cube([1.2, 4.5, stem_height + 0.1], true);
            cube([4.5, 1.4, stem_height + 0.1], true);
        }
    }
}

module next_keycap() {
    keycap();
    translate([0, 0, enclosure_hole_depth + stopper_flange_height + button_height_above_enclosure_surface - 0.1]) cylinder(h = symbol_height, d = 12, $fn = 3);
}
module prev_keycap() {
    keycap();    
    rotate([0, 0, 180]) translate([0, 0, enclosure_hole_depth + stopper_flange_height + button_height_above_enclosure_surface - 0.1]) cylinder(h = symbol_height, d = 12, $fn = 3);
}
module vol_up_keycap() {
    keycap();
    translate([0, 0, enclosure_hole_depth + stopper_flange_height + button_height_above_enclosure_surface - 0.1]) cylinder(h = symbol_height, d = 12, $fn = 5);
}
module vol_down_keycap() {
    keycap();
    translate([0, 0, enclosure_hole_depth + stopper_flange_height + button_height_above_enclosure_surface - 0.1]) cylinder(h = symbol_height, d = 6, $fn = 5);
}

//keycap();

// Stem only:
intersection() {
    keycap();
    translate([0, 0, -1.5]) cube([8, 6, 5], true);
}