Created
May 23, 2013 00:48
-
-
Save borgstrom/5632044 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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