$(function () {
    // HACK: This should be window.Terminal once upgraded to 4.0.1
    var term = new window.Terminal.Terminal();
    term.open(document.getElementById('terminal'));

    function runFakeTerminal() {
        if (term._initialized) {
            return;
        }

        term._initialized = true;

        term.prompt = () => {
            term.write('\r\n$ ');
        };

        term.writeln('Welcome to xterm.js');
        term.writeln('This is a local terminal emulation, without a real terminal in the back-end.');
        term.writeln('Type some keys and commands to play around.');
        term.writeln('');
        prompt(term);

        term.onKey(e => {
            const printable = !e.domEvent.altKey && !e.domEvent.altGraphKey && !e.domEvent.ctrlKey && !e.domEvent.metaKey;

            if (e.domEvent.keyCode === 13) {
                prompt(term);
            } else if (e.domEvent.keyCode === 8) {
                // Do not delete the prompt
                if (term._core.buffer.x > 2) {
                    term.write('\b \b');
                }
            } else if (printable) {
                term.write(e.key);
            }
        });
    }

    function prompt(term) {
      term.write('\r\n$ ');
    }
    runFakeTerminal();
});
@@ -664,19 +664,20 @@
  term.on
-Key
+Data
 (e =%3E %7B%0A
@@ -690,250 +690,185 @@
     
-  const printable = !e.domEvent.altKey && !e.domEvent.altGraphKey && !e.domEvent.ctrlKey && !e.domEvent.metaKey;%0A%0A            if (e.domEvent.keyCode === 13) %7B%0A                prompt(term);%0A            %7D else if (e.domEvent.keyCode === 8) %7B%0A  
+switch (e) %7B%0A            case '%5Cr': // Enter%0A            case '%5Cu0003': // Ctrl+C%0A              prompt(term);%0A              break;%0A            case '%5Cu007F': // Backspace (DEL)%0A
     
@@ -915,26 +915,24 @@
             
-  
 if (term._co
@@ -958,36 +958,32 @@
                 
- 
-   
 term.write('%5Cb %5C
@@ -983,26 +983,24 @@
 e('%5Cb %5Cb');%0A
-  
             
@@ -1019,34 +1019,77 @@
     
-%7D else if (printable) %7B%0A  
+  break;%0A            default: // Print all other characters for demo%0A
     
@@ -1114,17 +1114,11 @@
 te(e
-.key
 );%0A
-  
     

Use onData in website demo