What would be the code for moving onto a new screen after a user presses a key. For example I have coded a blank screen that says press any key to begin.
I have been looking all over the web, but I am unable to find such a code that does not involve jQuery etc.
Thank you in advance.
<script>
//created a variable for instructions
var instructions = '<h1><center>You will see three different symbols appear</center></h1>';
//Created a button
var button = document.createElement('button');
button.innerHTML = 'Click here to Start';
var body = document.getElementsByTagName('body')[0];
body.appendChild(button);
button.addEventListener('click', function(){
if('click'){
document.open(newPage)
}
});
//Pressing a key (space bar in this case) will open up a blank page with the instructions of the experiment
document.addEventListener('keydown',function(e){
if(e.keyCode==32){
document.location.href=('about:blank');
document.write(instructions)
}
});
</script>