opt_color.attachEvent("onclick", do_color);
opt_paste.attachEvent("onclick", do_paste);
}
- $('term').onkeypress=keypress;
- $('term').onkeydown=keydown;
+ // If tabIndex works, only grab keyboard events when terminal is focused
+ // Otherwise, grab from whole document (e.g. in Safari).
+ var focus_element = document;
+ if(typeof $('term').tabIndex != "undefined") {
+ focus_element = $('term');
+ focus_element.focus();
+ }
+ focus_element.onkeypress=keypress;
+ focus_element.onkeydown=keydown;
force=true;
timeout=window.setTimeout(update,100);
}