building a typewriter with p5.js

Thanks to Allison Parrish sharing her code on I am currently working on an infroamtion design project which is based on the idea of lost in translation, from the inspiration from Parrish, I programmed a typewriter which goes wrong (the letter shown upside down on the screen). I tried to use the createGraphics() and then rotate the image, but it didn't work somehow, then I used translate() and rotate() in p5.js reference, but I struggled to make the letter appears on the left top corner rather than the right bottom corner, and also I have problem with swtiching lines, letters only go to the next line if I use backspace when I type, but I would like to use ENTER to control just like we normally do.

Anyone can help fix the problem please?

    var contents = "";
    var r,g,b;
    var bell;
    var ding;
    // var img;
    var button;

    function preload(){
      bell = loadSound('typing.wav');
      ding = loadSound('return.wav')
      // img = loadImage('paper.jpg');

    function setup() { 
      // image(img,0,0,600,400);
      button = createButton("Savs as image");

    function draw() {

    function keyTyped() {
      contents += key;
      r = random(255);
      g = random(255);
      b = random(255);;

    function keyPressed() {
      if (keyCode === ENTER) {;

    function saveImg(){
      saveFrames('library/Your text', 'png', 1,1);


  • Like I said in your last question, you're going to have better luck if you post a more specific technical question. Saying "it didn't work somehow" doesn't give us any information to work from. And we can't run this code, because it requires files we don't have. Can you please post a MCVE and a more specific technical question?

    Which line of code is behaving differently from what you expected? Isolate that into its own example program that demonstrates the behavior without any extra code.

Sign In or Register to comment.