<p>I'm using <kbd>Ctrl</kbd>+<kbd>Left</kbd> / <kbd>Ctrl</kbd>+<kbd>Right</kbd> in a GreaseMonkey script as a hotkey to turn back / forward pages. It seems to works fine, but I want to disable this behavior if I'm in a text edit area. I'm trying to use document.activeElement to get the page active element and test if it's an editable area, but it always returns "undefined".</p>

document.activeElement works for me in FF3 but the following also works
```
```
(function() {

var myActiveElement;
document.onkeypress = function(event) {
    if ((myActiveElement || document.activeElement || {}).tagName != 'INPUT')
        // do your magic
};
if (!document.activeElement) {
    var elements = document.getElementsByTagName('input');
    for(var i=0; i<elements.length; i++) {
        elements[i].addEventListener('focus',function() {
            myActiveElement = this;
        },false);
        elements[i].addEventListener('blur',function() {
            myActiveElement = null;
        },false);
    }
}

})();
```
```