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
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