EDIT: using BrowserWindow.
What the simplest/best way to launch javascript commands in a webpage one after the other ?  (asynchronous, not synchronous)
For example, several document.write triggered by a keypress event.
document.write("line 1");
wait_for_key_press();
document.write("line 2");
wait_for_key_press();
document.write("line 3");
wait_for_key_press();
document.write("line 4");
...
function wait_for_key_press(){
 ...
}
 
     
    