This's my code for adding eventListener of google/code-prettify what I want to achieve is displaying the code as a code when the user insert his code in the textarea it should be working but for some reason it doesn't
<body onload="PR.prettyPrint()">
<h1>Insert your code</h1>
<form method="POST">
<pre class=" prettyprint"> <code class=" prettyprint"> <?php echo htmlspecialchars($str); ?> </code></pre>
<div class=" prettyprint"> <textarea id="testcode" class=" prettyprint" id="code"> </textarea></div>
<script lang="javascript">
document.getElementById("testcode").addEventListener('onkeyup', PR.prettyPrint, false);
document.getElementById("testcode").innerText = "echo";
</script>
<input type="submit"></input>
</form>
</body>
The textarea and an example of printed code using the lib.
Documentation Documentation If you are calling prettyPrint via an event handler, wrap it in a function. Instead of doing:
addEventListener('load', PR.prettyPrint, false);
wrap it in a closure like:
addEventListener('onkeyup', function(event) { PR.prettyPrint(); }, false);


