I have a basic typing animation that triggers when space bar is pressed, but I would like to be able to do it multiple times and on different lines. I need help on how I would go about coding that.
Code:
<!DOCTYPE html>
<html>
<head>
	<title>Test</title>
	<meta charset = "UTF-8">
	<style>
		body{
			background: black;
		}
		p{
			color: green;
			font-family: monospace;
		}
	</style>
</head>
<body>
	<p id="1"> </p>
	<script>
		var i = 0;
		var txt = "This is some cool text!";
		document.addEventListener("keydown", function(){
			var keycode = event.keyCode;
			if(keycode === 32){
				typeWriter();
			}
		});
		function typeWriter() {
  			if (i < txt.length) {
				document.getElementById(1).innerHTML += txt.charAt(i);
				i++;
				setTimeout(typeWriter, 78);
			}
		}
	</script>
</body>
</html>