Last active
May 15, 2020 13:47
-
-
Save abuduba/90e8e0e9f3fe5479d9a49a52afbe04e2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import { createContext } from './hotkeys'; | |
const c = createContext(); | |
// Alerts when "no way" is typed in. | |
c.register('n o space w a y', () => { | |
alert('Yes way!'); | |
}); | |
/* | |
It replaces the native search behaviour when pressing ctrl+f | |
Note, the callback gets the event from the last key, | |
that is matched in the given sequence | |
*/ | |
c.register('ctrl+f', (event) => { | |
// prevent the native search behavior | |
event.preventDefault(); | |
const value = prompt('What you are looking for?'); | |
window.location.href = `https://www.google.com/?q=${value}`; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment