Skip to content

Instantly share code, notes, and snippets.

@henriksommerfeld
Last active January 12, 2021 20:07
Show Gist options
  • Save henriksommerfeld/9610341affe9885aa839c2a1480077dd to your computer and use it in GitHub Desktop.
Save henriksommerfeld/9610341affe9885aa839c2a1480077dd to your computer and use it in GitHub Desktop.
Shortcut for putting focus on searchbox using cjs extension for chromium browsers
document.addEventListener('keydown', function (event) {
if (event.ctrlKey && event.key === 'f') {
const box = document.getElementById('search_form_input');
box.focus();
box.value = '';
window.scroll(0,0);
}
});
document.addEventListener('keydown', function (event) {
if (event.ctrlKey && event.key === 'f') {
const box = document.getElementById('q');
box.focus();
box.value = '';
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment