Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save borgstrom/5632044 to your computer and use it in GitHub Desktop.
Save borgstrom/5632044 to your computer and use it in GitHub Desktop.
//
// 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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment