document.addEventListener('keydown', updateChar); document.addEventListener('keyup', stopChar); var i = 0; var txt = ''; var speed = 50; var keyisdown = 0; var newpercentage = 0; var tempwdth = 50; var tempXTRA = 400; var tempXOPQ = 60; var fontstring = 'font-variation-settings: "wdth" 50, "XTRA" 400, "XOPQ" 60;'; //------- experiment with keydown keyup var timer; function updateChar(e) { // console.log(e); if(keyisdown == 0){typeWriter()}; keyisdown = 1; if(timer) return; timer= setInterval(growLetter, 1); } function stopChar() { keyisdown = 0; clearInterval(timer); timer= null; tempwdth = 50; tempXTRA = 400; tempXOPQ = 60; } //--------------the typewriter stuff function typeWriter() { //clear the html initially for a text if (i === 0) document.getElementById("current").innerHTML = ''; if (i < txt.length) { restoreText(); document.getElementById("current").innerHTML += ""+txt.charAt(i)+""; i++; if(txt.charAt(i-1)==" "){typeWriter()}; } if(i==txt.length){ clearText(); i++; setTimeout(newQuote, 4000); } } var quotes = [ "I was a designer, a weapons designer. I made a drone for a friend but he used it for evil. A woman got hurt, we were eating jelly. When he died she would go in an orphanage. My stomach was going to explode. I finished painting my red warning signs. ", "I was giving out to my colleague and I was opening drawers in my office and I was like, just use this grid and the drawers were full of grids and I was giving them to her and saying just use those grids why don't we use those grids. ", "I was in a plane and I was the pilot but I didnt know how to fly and the police said I was a terrorist but I needed to do my laundry and I couldnt get everything done and I tried to do an emergency landing in the metro station. ", "I had this dream I was in the studio but it was my colleague's back garden and our work friends were there but as chickens and it really grossed me out. ", "I had a dream about something in paged.js that I did and you did and we had to resolve the conflict. ", "The adobe product: one mega program that does all the things from all the programs. Spaghetti dress: one long spaghetto that wraps around like a dress ends on the neck like a little curl. " ] //var quotes = ["test1.", "test2."] function newQuote() { //set the typing text txt = quotes[Math.floor(Math.random() * quotes.length)]; //reset the index i = 0; } function clearText(){ document.getElementById('current').classList.add("disappear"); } function restoreText(){ document.getElementById('current').classList.remove("disappear"); } function growLetter() { targetwdth = 151; targetXTRA = 603; targetXOPQ = 175; document.getElementById(i-1).style.fontVariationSettings = "\"wdth\" " + tempwdth + ", \"XTRA\" " + tempXTRA + ", \"XOPQ\" " + tempXOPQ; tempwdth++; tempXTRA++; // tempXOPQ++; } newQuote();