Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. Evan Borgstrom created this gist May 23, 2013.
    23 changes: 23 additions & 0 deletions activecollab-global-search-key-userscript.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    //
    // This is a userscript for activecollab that allows for you to press the 's'
    // key on any page and have it focus the search input box allowing for quick
    // searching.
    //
    // author: Evan Borgstrom (@borgstrom)
    // license: MIT
    //

    window.onkeydown = function(event) {
    // only work when the body is focused
    if (document.activeElement != document.body) {
    return;
    }

    // look for the "s" key
    if (event.keyCode == 83) {
    // focus the search input element and prevent the event
    // propagation so 's' doesn't end up in the input
    document.getElementsByName("q")[0].focus();
    return false;
    }
    }