Make ajaxterm only seize keypresses when focused.
authorEric Price <ecprice@mit.edu>
Fri, 21 Aug 2009 16:13:43 +0000 (12:13 -0400)
committerEric Price <ecprice@mit.edu>
Fri, 21 Aug 2009 16:13:43 +0000 (12:13 -0400)
svn path=/package_branches/invirt-web/ajaxterm-rebased/; revision=2758

code/static/ajaxterm/ajaxterm.js
code/templates/terminal.mako

index 9089a96..8d44037 100644 (file)
@@ -272,8 +272,8 @@ ajaxterm.Terminal_ctor=function(id,machine_id) {
                        opt_color.attachEvent("onclick", do_color);
                        opt_paste.attachEvent("onclick", do_paste);
                }
-               document.onkeypress=keypress;
-               document.onkeydown=keydown;
+               $('term').onkeypress=keypress;
+               $('term').onkeydown=keydown;
                force=true;
                timeout=window.setTimeout(update,100);
        }
index 7df313d..9f1854f 100644 (file)
@@ -21,9 +21,10 @@ ${parent.header_extra()}
 <script type="text/javascript">
 window.onload=function() {
        t=ajaxterm.Terminal("term", ${machine.machine_id});
+        $('term').focus();
 }
 </script>
 </%def>
 
-<div id="term"></div>
+<div tabindex="0" id="term"></div>
 <div style="clear: both;"></div>