# Typewriter generator based on speed

**URL:** https://discourse.processing.org/t/typewriter-generator-based-on-speed/11114
**Category:** Gallery
**Created:** [May 10, 2019, 4:50pm UTC](https://discourse.processing.org/t/typewriter-generator-based-on-speed/11114 "2019-05-10T16:50:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![smekis](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@smekis](https://discourse.processing.org/u/smekis)
#### Post date: [May 10, 2019, 4:50pm UTC](https://discourse.processing.org/t/typewriter-generator-based-on-speed/11114/1 "2019-05-10T16:50:03Z")

</div>

Codepen: [https://codepen.io/danborjesson/pen/xNVzJM](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

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 10, 2019, 7:55pm UTC](https://discourse.processing.org/t/typewriter-generator-based-on-speed/11114/2 "2019-05-10T19:55:05Z")

</div>

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

```auto
// 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
//

```

---

<div class="post-metadata">

### Author: ![smekis](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@smekis](https://discourse.processing.org/u/smekis)
#### Post date: [May 13, 2019, 10:38am UTC](https://discourse.processing.org/t/typewriter-generator-based-on-speed/11114/3 "2019-05-13T10:38:19Z")

</div>

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

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

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 13, 2019, 11:40am UTC](https://discourse.processing.org/t/typewriter-generator-based-on-speed/11114/4 "2019-05-13T11:40:51Z")

</div>

> [@How to ask a question and receive and answer](https://discourse.processing.org/t/how-to-ask-a-question-and-receive-and-answer/10814/2):
>
> Button [https://processing.org/examples/button.html](https://processing.org/examples/button.html) Keys [https://processing.org/examples/keyboardfunctions.html](https://processing.org/examples/keyboardfunctions.html) There are more examples Example (see also below) you can get an input in the above example by result = result + key; if (key==RETURN || key==ENTER) { // input is entered, proceed with next variable result2 } I like Scratch and I think processing is useful to go on from Scratch, so welcome!
