По нажатию на enter
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Стили</title>
</head>
<body>
<div class="fixed-textarea"> <textarea name ="tt" id="tt" style="height: 100%;width: 100%;" > </textarea></div>
<div id="result"></div>
<script language="JavaScript">
var text = '>> Сколько лет земле ? \r\n >> ',
i=0,
textInput = document.getElementById("tt"),
result = document.getElementById("result");
function type(){
i++;
if( i <= text.length )
document.getElementById("tt").innerHTML = text.substr(0, i);
setTimeout( type, 50 );
}
function one(){
var k= Math.random();
var tex=document.getElementById('tt').value;
setTimeout( type, 10 );
}
type();
textInput.addEventListener('keyup', function(e){
if(e.keyCode == 13){
var answer = e.target.value.split('>>')
result.innerHTML = answer[answer.length-1]
}
})
</script>
</body>
</html>