Skip to content

Instantly share code, notes, and snippets.

Forked from abuduba/hotkeys-usage.js
Created May 15, 2020 13:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
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
const value = prompt('What you are looking for?');
window.location.href = `${value}`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment