Typewriter generator based on speed

Codepen: https://codepen.io/danborjesson/pen/xNVzJM

I’ve created a typewriter generator. Nothing special but the font-weight changes when hovering. I created that just to see that it’s possible to change the font-weight on the font. Now I will try to find a way to change the font-weight on every letter depending on how long it takes for the user to press the next key.

If you type fast the font-weight of that letter gets big and if you type slow the font-weight gets smaller.

Anyone knows how or can help me on the way?

/S

2 Likes

this example measures how long you hold a key down while typing

// a test
int timer = 0; 
int timerResult = 0; 
boolean down=false; 

// ---------------------------------------------------------------

void setup() {
  // init (runs only once)
  size(800, 600);
} // func 

void draw() { 
  // runs on and on 
  background(255);

  fill(244, 3, 3); // red 
  text (timerResult, 10, 13);
} // func 

void keyPressed() {
  if (!down) {
    timer=millis();
    down=true;
  }
} // func

void keyReleased() {
  if (down) {
    timerResult = millis()-timer;
    down=false;
  }
} // func
//
3 Likes

Thank you Chrisir, I solved it this way
https://codepen.io/danborjesson/pen/YbGVZJ

Now I’m trying to save the types that been written, but that seems really hard.